diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2000-12-18 23:50:58 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2000-12-18 23:50:58 +0000 |
commit | 20d380b15db740b9a998f5c64b52333f3f8d55c2 (patch) | |
tree | 833e6694e53e2262c29a25430e076b0022d4b539 /gcc | |
parent | e2ef2bf880b8c33ac444c6fdf4e6afc2852ff19b (diff) | |
download | gcc-20d380b15db740b9a998f5c64b52333f3f8d55c2.zip gcc-20d380b15db740b9a998f5c64b52333f3f8d55c2.tar.gz gcc-20d380b15db740b9a998f5c64b52333f3f8d55c2.tar.bz2 |
c-common.c (STD_C9L, ADJ_STD): Define.
* c-common.c (STD_C9L, ADJ_STD): Define.
(printf_length_specs, scanf_length_specs): Mark "ll" as standard
STD_C9L.
(T99_LL): Rename to T9L_LL.
(T99_ULL): Rename to T9L_ULL.
(print_char_table, scan_char_table): Use T9L_LL and T9L_ULL
instead of T99_LL and T99_ULL.
(check_format_info_main): Use ADJ_STD on all format standard
versions being compared.
* c-common.h: Declare warn_long_long.
* c-tree.h: Don't declare warn_long_long.
cp:
* cp-tree.h: Don't declare warn_long_long.
testsuite:
* gcc.dg/format-warnll-1.c: New test.
From-SVN: r38369
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/c-common.c | 46 | ||||
-rw-r--r-- | gcc/c-common.h | 5 | ||||
-rw-r--r-- | gcc/c-tree.h | 4 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format-warnll-1.c | 46 |
8 files changed, 99 insertions, 28 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index adbd02c..c593d1e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,19 @@ 2000-12-18 Joseph S. Myers <jsm28@cam.ac.uk> + * c-common.c (STD_C9L, ADJ_STD): Define. + (printf_length_specs, scanf_length_specs): Mark "ll" as standard + STD_C9L. + (T99_LL): Rename to T9L_LL. + (T99_ULL): Rename to T9L_ULL. + (print_char_table, scan_char_table): Use T9L_LL and T9L_ULL + instead of T99_LL and T99_ULL. + (check_format_info_main): Use ADJ_STD on all format standard + versions being compared. + * c-common.h: Declare warn_long_long. + * c-tree.h: Don't declare warn_long_long. + +2000-12-18 Joseph S. Myers <jsm28@cam.ac.uk> + * COPYING: Update to current ftp://ftp.gnu.org/pub/gnu/Licenses/COPYING-2.0 (fixes references to 19yy as example year in copyright notice). diff --git a/gcc/c-common.c b/gcc/c-common.c index 64e3683..a1970e2 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1316,6 +1316,7 @@ enum format_std_version { STD_C89, STD_C94, + STD_C9L, /* C99, but treat as C89 if -Wno-long-long. */ STD_C99, STD_EXT }; @@ -1337,6 +1338,11 @@ enum format_std_version : ((FEATURE_VER) == STD_EXT \ ? "ISO C" \ : "ISO C89")) +/* Adjust a C standard version, which may be STD_C9L, to account for + -Wno-long-long. Returns other standard versions unchanged. */ +#define ADJ_STD(VER) ((int)((VER) == STD_C9L \ + ? (warn_long_long ? STD_C99 : STD_C89) \ + : (VER))) /* Flags that may apply to a particular kind of format checked by GCC. */ enum @@ -1548,7 +1554,7 @@ typedef struct format_wanted_type static const format_length_info printf_length_specs[] = { { "h", FMT_LEN_h, STD_C89, "hh", FMT_LEN_hh, STD_C99 }, - { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C99 }, + { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L }, { "q", FMT_LEN_ll, STD_EXT, NULL, 0, 0 }, { "L", FMT_LEN_L, STD_C89, NULL, 0, 0 }, { "z", FMT_LEN_z, STD_C99, NULL, 0, 0 }, @@ -1563,7 +1569,7 @@ static const format_length_info printf_length_specs[] = static const format_length_info scanf_length_specs[] = { { "h", FMT_LEN_h, STD_C89, "hh", FMT_LEN_hh, STD_C99 }, - { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C99 }, + { "l", FMT_LEN_l, STD_C89, "ll", FMT_LEN_ll, STD_C9L }, { "q", FMT_LEN_ll, STD_EXT, NULL, 0, 0 }, { "L", FMT_LEN_L, STD_C89, NULL, 0, 0 }, { "z", FMT_LEN_z, STD_C99, NULL, 0, 0 }, @@ -1649,7 +1655,7 @@ static const format_flag_pair strftime_flag_pairs[] = #define T_L &long_integer_type_node #define T89_L { STD_C89, NULL, T_L } #define T_LL &long_long_integer_type_node -#define T99_LL { STD_C99, NULL, T_LL } +#define T9L_LL { STD_C9L, NULL, T_LL } #define TEX_LL { STD_EXT, NULL, T_LL } #define T_S &short_integer_type_node #define T89_S { STD_C89, NULL, T_S } @@ -1659,7 +1665,7 @@ static const format_flag_pair strftime_flag_pairs[] = #define T_UL &long_unsigned_type_node #define T89_UL { STD_C89, NULL, T_UL } #define T_ULL &long_long_unsigned_type_node -#define T99_ULL { STD_C99, NULL, T_ULL } +#define T9L_ULL { STD_C9L, NULL, T_ULL } #define TEX_ULL { STD_EXT, NULL, T_ULL } #define T_US &short_unsigned_type_node #define T89_US { STD_C89, NULL, T_US } @@ -1702,15 +1708,15 @@ static const format_flag_pair strftime_flag_pairs[] = static const format_char_info print_char_table[] = { /* C89 conversion specifiers. */ - { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T99_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i" }, - { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T99_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i" }, - { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T99_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i" }, + { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i" }, + { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i" }, + { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i" }, { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "" }, { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "" }, { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "" }, { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR" }, { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c" }, - { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T99_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" }, + { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" }, /* C99 conversion specifiers. */ { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "" }, { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "" }, @@ -1725,15 +1731,15 @@ static const format_char_info print_char_table[] = static const format_char_info scan_char_table[] = { /* C89 conversion specifiers. */ - { "di", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T99_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "*w'I", "W" }, - { "u", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T99_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w'I", "W" }, - { "oxX", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T99_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w", "W" }, + { "di", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "*w'I", "W" }, + { "u", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w'I", "W" }, + { "oxX", 1, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "*w", "W" }, { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "*w'", "W" }, { "c", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW" }, { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW" }, { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[" }, { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W" }, - { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T99_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" }, + { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" }, /* C99 conversion specifiers. */ { "FaA", 1, STD_C99, { T99_F, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "*w'", "W" }, /* X/Open conversion specifiers. */ @@ -2901,7 +2907,7 @@ check_format_info_main (status, res, info, format_chars, format_length, if (pedantic) { /* Warn if the length modifier is non-standard. */ - if (length_chars_std > C_STD_VER) + if (ADJ_STD (length_chars_std) > C_STD_VER) status_warning (status, "%s does not support the `%s' %s length modifier", C_STD_NAME (length_chars_std), length_chars, fki->name); @@ -2971,7 +2977,7 @@ check_format_info_main (status, res, info, format_chars, format_length, } if (pedantic) { - if (fci->std > C_STD_VER) + if (ADJ_STD (fci->std) > C_STD_VER) status_warning (status, "%s does not support the `%%%c' %s format", C_STD_NAME (fci->std), format_char, fki->name); } @@ -2996,16 +3002,16 @@ check_format_info_main (status, res, info, format_chars, format_length, if (pedantic) { const format_flag_spec *t; - if (s->std > C_STD_VER) + if (ADJ_STD (s->std) > C_STD_VER) status_warning (status, "%s does not support %s", C_STD_NAME (s->std), _(s->long_name)); t = get_flag_spec (flag_specs, flag_chars[i], fci->flags2); - if (t != NULL && t->std > s->std) + if (t != NULL && ADJ_STD (t->std) > ADJ_STD (s->std)) { const char *long_name = (t->long_name != NULL ? t->long_name : s->long_name); - if (t->std > C_STD_VER) + if (ADJ_STD (t->std) > C_STD_VER) status_warning (status, "%s does not support %s with the `%%%c' %s format", C_STD_NAME (t->std), _(long_name), format_char, fki->name); @@ -3121,10 +3127,10 @@ check_format_info_main (status, res, info, format_chars, format_length, /* Warn if non-standard, provided it is more non-standard than the length and type characters that may already have been warned for. */ - && wanted_type_std > length_chars_std - && wanted_type_std > fci->std) + && ADJ_STD (wanted_type_std) > ADJ_STD (length_chars_std) + && ADJ_STD (wanted_type_std) > ADJ_STD (fci->std)) { - if (wanted_type_std > C_STD_VER) + if (ADJ_STD (wanted_type_std) > C_STD_VER) status_warning (status, "%s does not support the `%%%s%c' %s format", C_STD_NAME (wanted_type_std), length_chars, format_char, fki->name); diff --git a/gcc/c-common.h b/gcc/c-common.h index 437d95d..b31499f 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -416,6 +416,11 @@ extern int warn_parentheses; extern int warn_conversion; +/* Nonzero means warn about usage of long long, + when `-pedantic' and not C99. */ + +extern int warn_long_long; + /* C types are partitioned into three subsets: object, function, and incomplete types. */ #define C_TYPE_OBJECT_P(type) \ diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 41a6075..ee769e7 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -373,10 +373,6 @@ extern int warn_float_equal; extern int warn_multichar; -/* Warn about long long. */ - -extern int warn_long_long; - /* Nonzero means we are reading code that came from a system header file. */ extern int system_header_p; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa5313e..9804092 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2000-12-18 Joseph S. Myers <jsm28@cam.ac.uk> + + * cp-tree.h: Don't declare warn_long_long. + 2000-12-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> * tree.c (no_linkage_helper): Use CLASS_TYPE_P instead of diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9fcbcc2..d7ede4e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1019,10 +1019,6 @@ extern int flag_gnu_binutils; extern int warn_implicit; -/* Nonzero means warn about usage of long long when `-pedantic'. */ - -extern int warn_long_long; - /* Nonzero means warn when all ctors or dtors are private, and the class has no friends. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ebf446..b60cda7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-12-18 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.dg/format-warnll-1.c: New test. + 2000-12-18 Neil Booth <neil@daikokuya.demon.co.uk> * gcc.dg/cpp/cmdlne-P.c: New test. diff --git a/gcc/testsuite/gcc.dg/format-warnll-1.c b/gcc/testsuite/gcc.dg/format-warnll-1.c new file mode 100644 index 0000000..71a749b --- /dev/null +++ b/gcc/testsuite/gcc.dg/format-warnll-1.c @@ -0,0 +1,46 @@ +/* Test for printf formats. C99 "long long" formats should be accepted with + -Wno-long-long. +*/ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-long" } */ + +extern int printf (const char *, ...); +extern int scanf (const char *, ...); + +void +foo (long long ll, unsigned long long ull, long long *lln, + long long *llp, unsigned long long *ullp) +{ + /* Test for accepting standard "long long" formats. */ + printf ("%lld%lli%llo%llu%llx%llX%lln", ll, ll, ull, ull, ull, ull, lln); + scanf ("%lld%lli%llo%llu%llx%llX%lln", llp, llp, + ullp, ullp, ullp, ullp, lln); + /* Use of "q" and "L" should still be warned about. */ + printf ("%qd", ll); /* { dg-warning "C" "printf %qd" } */ + printf ("%qi", ll); /* { dg-warning "C" "printf %qi" } */ + printf ("%qo", ull); /* { dg-warning "C" "printf %qo" } */ + printf ("%qu", ull); /* { dg-warning "C" "printf %qu" } */ + printf ("%qx", ull); /* { dg-warning "C" "printf %qx" } */ + printf ("%qX", ull); /* { dg-warning "C" "printf %qX" } */ + printf ("%qn", lln); /* { dg-warning "C" "printf %qn" } */ + printf ("%Ld", ll); /* { dg-warning "C" "printf %Ld" } */ + printf ("%Li", ll); /* { dg-warning "C" "printf %Li" } */ + printf ("%Lo", ull); /* { dg-warning "C" "printf %oL" } */ + printf ("%Lu", ull); /* { dg-warning "C" "printf %Lu" } */ + printf ("%Lx", ull); /* { dg-warning "C" "printf %Lx" } */ + printf ("%LX", ull); /* { dg-warning "C" "printf %LX" } */ + scanf ("%qd", llp); /* { dg-warning "C" "scanf %qd" } */ + scanf ("%qi", llp); /* { dg-warning "C" "scanf %qi" } */ + scanf ("%qo", ullp); /* { dg-warning "C" "scanf %qo" } */ + scanf ("%qu", ullp); /* { dg-warning "C" "scanf %qu" } */ + scanf ("%qx", ullp); /* { dg-warning "C" "scanf %qx" } */ + scanf ("%qX", ullp); /* { dg-warning "C" "scanf %qX" } */ + scanf ("%qn", lln); /* { dg-warning "C" "scanf %qn" } */ + scanf ("%Ld", llp); /* { dg-warning "C" "scanf %Ld" } */ + scanf ("%Li", llp); /* { dg-warning "C" "scanf %Li" } */ + scanf ("%Lo", ullp); /* { dg-warning "C" "scanf %oL" } */ + scanf ("%Lu", ullp); /* { dg-warning "C" "scanf %Lu" } */ + scanf ("%Lx", ullp); /* { dg-warning "C" "scanf %Lx" } */ + scanf ("%LX", ullp); /* { dg-warning "C" "scanf %LX" } */ +} |