{
{ "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C89, 0 },
{ "w", FMT_LEN_w, STD_C89, NO_FMT, 0 },
+ { "z", FMT_LEN_z, STD_C99, NO_FMT, 0 },
+ { "t", FMT_LEN_t, STD_C99, NO_FMT, 0 },
{ NO_FMT, NO_FMT, 0 }
};
by all pretty_printer instances within GCC. */
#define PP_FORMAT_CHAR_TABLE \
- { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
- { "ox", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
- { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
+ { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
+ { "ox", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, T99_ST, T99_UPD, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
+ { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, T99_ST, T99_UPD, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
{ "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, \
{ "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "pq", "cR", NULL }, \
{ "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "c", NULL }, \
static const format_char_info gcc_gfc_char_table[] =
{
/* C89 conversion specifiers. */
- { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
- { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
+ { "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
+ { "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, T99_ST, T99_UPD, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "cR", NULL },
if (source_size < result_size)
gfc_warning (OPT_Wsurprising,
"Intrinsic TRANSFER at %L has partly undefined result: "
- "source size %ld < result size %ld", &source->where,
- (long) source_size, (long) result_size);
+ "source size %zd < result size %zd", &source->where,
+ source_size, result_size);
return true;
}
{
enum { TYPE_CURRENTLOC, TYPE_LOCUS, TYPE_INTEGER, TYPE_UINTEGER,
TYPE_LONGINT, TYPE_ULONGINT, TYPE_LLONGINT, TYPE_ULLONGINT,
- TYPE_HWINT, TYPE_HWUINT, TYPE_CHAR, TYPE_STRING, NOTYPE };
+ TYPE_HWINT, TYPE_HWUINT, TYPE_CHAR, TYPE_STRING, TYPE_SIZE,
+ TYPE_SSIZE, TYPE_PTRDIFF, NOTYPE };
struct
{
int type;
unsigned HOST_WIDE_INT hwuintval;
char charval;
const char * stringval;
+ size_t sizeval;
+ ssize_t ssizeval;
+ ptrdiff_t ptrdiffval;
} u;
} arg[MAX_ARGS], spec[MAX_ARGS];
/* spec is the array of specifiers, in the same order as they
gcc_unreachable ();
break;
+ case 'z':
+ c = *format++;
+ if (c == 'u')
+ arg[pos].type = TYPE_SIZE;
+ else if (c == 'i' || c == 'd')
+ arg[pos].type = TYPE_SSIZE;
+ else
+ gcc_unreachable ();
+ break;
+
+ case 't':
+ c = *format++;
+ if (c == 'u' || c == 'i' || c == 'd')
+ arg[pos].type = TYPE_PTRDIFF;
+ else
+ gcc_unreachable ();
+ break;
+
case 'c':
arg[pos].type = TYPE_CHAR;
break;
arg[pos].u.hwuintval = va_arg (argp, unsigned HOST_WIDE_INT);
break;
+ case TYPE_SSIZE:
+ arg[pos].u.ssizeval = va_arg (argp, ssize_t);
+ break;
+
+ case TYPE_SIZE:
+ arg[pos].u.sizeval = va_arg (argp, size_t);
+ break;
+
+ case TYPE_PTRDIFF:
+ arg[pos].u.ptrdiffval = va_arg (argp, ptrdiff_t);
+ break;
+
case TYPE_CHAR:
arg[pos].u.charval = (char) va_arg (argp, int);
break;
else
error_hwint (spec[n++].u.hwuintval);
break;
+
+ case 'z':
+ format++;
+ if (*format == 'u')
+ error_uinteger (spec[n++].u.sizeval);
+ else
+ error_integer (spec[n++].u.ssizeval);
+ break;
+
+ case 't':
+ format++;
+ if (*format == 'u')
+ {
+ ptrdiff_t ptrdiffval = spec[n++].u.ptrdiffval;
+ if (sizeof (ptrdiff_t) == sizeof (int))
+ error_uinteger ((unsigned) ptrdiffval);
+ else if (sizeof (ptrdiff_t) == sizeof (long))
+ error_uinteger ((unsigned long) ptrdiffval);
+ else
+ error_uinteger (ptrdiffval);
+ }
+ else
+ error_integer (spec[n++].u.ptrdiffval);
+ break;
}
}
{
if (istart < 1)
{
- gfc_error ("Substring start index (%ld) at %L below 1",
- (long) istart, &e->ref->u.ss.start->where);
+ gfc_error ("Substring start index (%td) at %L below 1",
+ istart, &e->ref->u.ss.start->where);
return MATCH_ERROR;
}
if (iend > (ssize_t) length)
{
- gfc_error ("Substring end index (%ld) at %L exceeds string "
- "length", (long) iend, &e->ref->u.ss.end->where);
+ gfc_error ("Substring end index (%td) at %L exceeds string "
+ "length", iend, &e->ref->u.ss.end->where);
return MATCH_ERROR;
}
length = iend - istart + 1;
if (warn_line_truncation && c < e1)
gfc_warning_now (OPT_Wcharacter_truncation,
"CHARACTER expression will be truncated "
- "in constructor (%ld/%ld) at %L", (long int) c,
- (long int) e1, &actual->expr->where);
+ "in constructor (%td/%td) at %L", c,
+ e1, &actual->expr->where);
}
}
if (*p1++ != '<' || p[-2] != '>')
fatal_error (input_location,
"specs %%include syntax malformed after "
- "%ld characters",
- (long) (p1 - buffer + 1));
+ "%td characters", p1 - buffer + 1);
p[-2] = '\0';
new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true);
if (*p1++ != '<' || p[-2] != '>')
fatal_error (input_location,
"specs %%include syntax malformed after "
- "%ld characters",
- (long) (p1 - buffer + 1));
+ "%td characters", p1 - buffer + 1);
p[-2] = '\0';
new_filename = find_a_file (&startfile_prefixes, p1, R_OK, true);
if (! ISALPHA ((unsigned char) *p1))
fatal_error (input_location,
"specs %%rename syntax malformed after "
- "%ld characters",
- (long) (p1 - buffer));
+ "%td characters", p1 - buffer);
p2 = p1;
while (*p2 && !ISSPACE ((unsigned char) *p2))
if (*p2 != ' ' && *p2 != '\t')
fatal_error (input_location,
"specs %%rename syntax malformed after "
- "%ld characters",
- (long) (p2 - buffer));
+ "%td characters", p2 - buffer);
name_len = p2 - p1;
*p2++ = '\0';
if (! ISALPHA ((unsigned char) *p2))
fatal_error (input_location,
"specs %%rename syntax malformed after "
- "%ld characters",
- (long) (p2 - buffer));
+ "%td characters", p2 - buffer);
/* Get new spec name. */
p3 = p2;
if (p3 != p - 1)
fatal_error (input_location,
"specs %%rename syntax malformed after "
- "%ld characters",
- (long) (p3 - buffer));
+ "%td characters", p3 - buffer);
*p3 = '\0';
for (sl = specs; sl; sl = sl->next)
}
else
fatal_error (input_location,
- "specs unknown %% command after %ld characters",
- (long) (p1 - buffer));
+ "specs unknown %% command after %td characters",
+ p1 - buffer);
}
/* Find the colon that should end the suffix. */
/* The colon shouldn't be missing. */
if (*p1 != ':')
fatal_error (input_location,
- "specs file malformed after %ld characters",
- (long) (p1 - buffer));
+ "specs file malformed after %td characters",
+ p1 - buffer);
/* Skip back over trailing whitespace. */
p2 = p1;
p = skip_whitespace (p1 + 1);
if (p[1] == 0)
fatal_error (input_location,
- "specs file malformed after %ld characters",
- (long) (p - buffer));
+ "specs file malformed after %td characters",
+ p - buffer);
p1 = p;
/* Find next blank line or end of string. */
break; \
\
case 2: \
- pp_scalar (PP, "%" HOST_LONG_LONG_FORMAT F, va_arg (ARG, long long T)); \
+ pp_scalar (PP, "%" HOST_LONG_LONG_FORMAT F, \
+ va_arg (ARG, long long T)); \
+ break; \
+ \
+ case 3: \
+ if (T (-1) < T (0)) \
+ pp_scalar (PP, "%" GCC_PRISZ F, \
+ (fmt_size_t) va_arg (ARG, ssize_t)); \
+ else \
+ pp_scalar (PP, "%" GCC_PRISZ F, \
+ (fmt_size_t) va_arg (ARG, size_t)); \
+ break; \
+ \
+ case 4: \
+ if (sizeof (ptrdiff_t) <= sizeof (int)) \
+ pp_scalar (PP, "%" F, \
+ (int) va_arg (ARG, ptrdiff_t)); \
+ else if (sizeof (ptrdiff_t) <= sizeof (long)) \
+ pp_scalar (PP, "%l" F, \
+ (long int) va_arg (ARG, ptrdiff_t)); \
+ else \
+ pp_scalar (PP, "%" HOST_LONG_LONG_FORMAT F, \
+ (long long int) \
+ va_arg (ARG, ptrdiff_t)); \
break; \
\
default: \
%ld, %li, %lo, %lu, %lx: long versions of the above.
%lld, %lli, %llo, %llu, %llx: long long versions.
%wd, %wi, %wo, %wu, %wx: HOST_WIDE_INT versions.
+ %zd, %zi, %zo, %zu, %zx: size_t versions.
+ %td, %ti, %to, %tu, %tx: ptrdiff_t versions.
%f: double
%c: character.
%s: string.
obstack_1grow (&buffer->chunk_obstack, *p);
p++;
}
- while (strchr ("qwl+#", p[-1]));
+ while (strchr ("qwlzt+#", p[-1]));
if (p[-1] == '.')
{
wide = true;
continue;
+ case 'z':
+ gcc_assert (!precision);
+ precision = 3;
+ continue;
+
+ case 't':
+ gcc_assert (!precision);
+ precision = 4;
+ continue;
+
case 'l':
/* We don't support precision beyond that of "long long". */
gcc_assert (precision < 2);
if (wide)
pp_wide_integer (pp, va_arg (*text->m_args_ptr, HOST_WIDE_INT));
else
- pp_integer_with_precision
- (pp, *text->m_args_ptr, precision, int, "d");
+ pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+ int, "d");
break;
case 'o':
pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o",
va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
- pp_integer_with_precision
- (pp, *text->m_args_ptr, precision, unsigned, "o");
+ pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+ unsigned, "o");
break;
case 's':
pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED,
va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
- pp_integer_with_precision
- (pp, *text->m_args_ptr, precision, unsigned, "u");
+ pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+ unsigned, "u");
break;
case 'f':
pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
- pp_integer_with_precision
- (pp, *text->m_args_ptr, precision, unsigned, "x");
+ pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+ unsigned, "x");
break;
case '.':
ASSERT_PP_FORMAT_2 ("17 12345678", "%wo %x", (HOST_WIDE_INT)15, 0x12345678);
ASSERT_PP_FORMAT_2 ("0xcafebabe 12345678", "%wx %x", (HOST_WIDE_INT)0xcafebabe,
0x12345678);
+ ASSERT_PP_FORMAT_2 ("-27 12345678", "%zd %x", (ssize_t)-27, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("-5 12345678", "%zi %x", (ssize_t)-5, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("10 12345678", "%zu %x", (size_t)10, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("17 12345678", "%zo %x", (size_t)15, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("cafebabe 12345678", "%zx %x", (size_t)0xcafebabe,
+ 0x12345678);
+ ASSERT_PP_FORMAT_2 ("-27 12345678", "%td %x", (ptrdiff_t)-27, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("-5 12345678", "%ti %x", (ptrdiff_t)-5, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("10 12345678", "%tu %x", (ptrdiff_t)10, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("17 12345678", "%to %x", (ptrdiff_t)15, 0x12345678);
+ ASSERT_PP_FORMAT_2 ("1afebabe 12345678", "%tx %x", (ptrdiff_t)0x1afebabe,
+ 0x12345678);
ASSERT_PP_FORMAT_2 ("1.000000 12345678", "%f %x", 1.0, 0x12345678);
ASSERT_PP_FORMAT_2 ("A 12345678", "%c %x", 'A', 0x12345678);
ASSERT_PP_FORMAT_2 ("hello world 12345678", "%s %x", "hello world",