diff options
author | Tom Tromey <tromey@redhat.com> | 2011-03-14 17:58:12 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2011-03-14 17:58:12 +0000 |
commit | b3ab9ea2979fd0fcc2a3eff1f0c417c5e6f27f35 (patch) | |
tree | 2f7867edf299867952cbd5c600cffe758a60b115 /gcc | |
parent | d8d4db3345ec3271a5edf4bd84e999662cd8e2e2 (diff) | |
download | gcc-b3ab9ea2979fd0fcc2a3eff1f0c417c5e6f27f35.zip gcc-b3ab9ea2979fd0fcc2a3eff1f0c417c5e6f27f35.tar.gz gcc-b3ab9ea2979fd0fcc2a3eff1f0c417c5e6f27f35.tar.bz2 |
c-parser.c (disable_extension_diagnostics): Save warn_overlength_strings.
gcc
* c-parser.c (disable_extension_diagnostics): Save
warn_overlength_strings.
(restore_extension_diagnostics): Restore warn_overlength_strings.
gcc/testsuite
* gcc.dg/Woverlength-strings-pedantic-c89-ext.c: New file.
* gcc.dg/Woverlength-strings-pedantic-c90-ext.c: New file.
* gcc.dg/Woverlength-strings-pedantic-c99-ext.c: New file.
From-SVN: r170947
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-parser.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c | 19 |
6 files changed, 73 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ead0af..f1a353c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-14 Tom Tromey <tromey@redhat.com> + + * c-parser.c (disable_extension_diagnostics): Save + warn_overlength_strings. + (restore_extension_diagnostics): Restore warn_overlength_strings. + 2011-03-14 Jakub Jelinek <jakub@redhat.com> * BASE-VER: Change to 4.7.0. diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 69ce2e5..7b18827 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -1045,13 +1045,15 @@ disable_extension_diagnostics (void) | (warn_traditional << 2) | (flag_iso << 3) | (warn_long_long << 4) - | (warn_cxx_compat << 5)); + | (warn_cxx_compat << 5) + | (warn_overlength_strings << 6)); cpp_opts->cpp_pedantic = pedantic = 0; warn_pointer_arith = 0; cpp_opts->cpp_warn_traditional = warn_traditional = 0; flag_iso = 0; cpp_opts->cpp_warn_long_long = warn_long_long = 0; warn_cxx_compat = 0; + warn_overlength_strings = 0; return ret; } @@ -1067,6 +1069,7 @@ restore_extension_diagnostics (int flags) flag_iso = (flags >> 3) & 1; cpp_opts->cpp_warn_long_long = warn_long_long = (flags >> 4) & 1; warn_cxx_compat = (flags >> 5) & 1; + warn_overlength_strings = (flags >> 6) & 1; } /* Possibly kinds of declarator to parse. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8d3e847..6afb96d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-03-14 Tom Tromey <tromey@redhat.com> + + * gcc.dg/Woverlength-strings-pedantic-c89-ext.c: New file. + * gcc.dg/Woverlength-strings-pedantic-c90-ext.c: New file. + * gcc.dg/Woverlength-strings-pedantic-c99-ext.c: New file. + 2011-03-14 H.J. Lu <hongjiu.lu@intel.com> * gcc.target/i386/builtin-copysign.c: Remove __LP64__ check. diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c new file mode 100644 index 0000000..09b8079 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c new file mode 100644 index 0000000..6fbaebe --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c90 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c new file mode 100644 index 0000000..93d5e46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; |