1 2011-01-18 Tom Tromey <tromey@redhat.com>
3 * c-parser.c (disable_extension_diagnostics): Save
4 warn_overlength_strings.
5 (restore_extension_diagnostics): Restore warn_overlength_strings.
7 * gcc.dg/Woverlength-strings-pedantic-c89-ext.c: New file.
8 * gcc.dg/Woverlength-strings-pedantic-c90-ext.c: New file.
9 * gcc.dg/Woverlength-strings-pedantic-c99-ext.c: New file.
11 --- gcc/c-parser.c (revision 168933)
12 +++ gcc/c-parser.c (working copy)
13 @@ -1045,13 +1045,15 @@
14 | (warn_traditional << 2)
16 | (warn_long_long << 4)
17 - | (warn_cxx_compat << 5));
18 + | (warn_cxx_compat << 5)
19 + | (warn_overlength_strings << 6));
20 cpp_opts->cpp_pedantic = pedantic = 0;
21 warn_pointer_arith = 0;
22 cpp_opts->cpp_warn_traditional = warn_traditional = 0;
24 cpp_opts->cpp_warn_long_long = warn_long_long = 0;
26 + warn_overlength_strings = 0;
31 flag_iso = (flags >> 3) & 1;
32 cpp_opts->cpp_warn_long_long = warn_long_long = (flags >> 4) & 1;
33 warn_cxx_compat = (flags >> 5) & 1;
34 + warn_overlength_strings = (flags >> 6) & 1;
37 /* Possibly kinds of declarator to parse. */
38 --- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0)
39 +++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0)
41 +/* -Woverlength-strings complains about string constants which are too long
42 + for the C standard's "minimum maximum" limits. It is off by default,
43 + but implied by -pedantic. */
45 +/* { dg-options "-std=c89 -pedantic" } */
47 +#define TEN "xxxxxxxxxx"
48 +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
49 +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
51 +/* C89's minimum-maximum is 509. */
52 +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN;
54 +/* C99's minimum-maximum is 4095. */
55 +const char x4096[] = __extension__
56 + THO THO THO THO /* 4000 */
57 + TEN TEN TEN TEN TEN /* 4050 */
58 + TEN TEN TEN TEN /* 4090 */
60 --- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0)
61 +++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0)
63 +/* -Woverlength-strings complains about string constants which are too long
64 + for the C standard's "minimum maximum" limits. It is off by default,
65 + but implied by -pedantic. */
67 +/* { dg-options "-std=c90 -pedantic" } */
69 +#define TEN "xxxxxxxxxx"
70 +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
71 +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
73 +/* C89's minimum-maximum is 509. */
74 +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN;
76 +/* C99's minimum-maximum is 4095. */
77 +const char x4096[] = __extension__
78 + THO THO THO THO /* 4000 */
79 + TEN TEN TEN TEN TEN /* 4050 */
80 + TEN TEN TEN TEN /* 4090 */
82 --- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0)
83 +++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0)
85 +/* -Woverlength-strings complains about string constants which are too long
86 + for the C standard's "minimum maximum" limits. It is off by default,
87 + but implied by -pedantic. */
89 +/* { dg-options "-std=c99 -pedantic" } */
91 +#define TEN "xxxxxxxxxx"
92 +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
93 +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
95 +/* C89's minimum-maximum is 509. */
96 +const char x510[] = HUN HUN HUN HUN HUN TEN;
98 +/* C99's minimum-maximum is 4095. */
99 +const char x4096[] = __extension__
100 + THO THO THO THO /* 4000 */
101 + TEN TEN TEN TEN TEN /* 4050 */
102 + TEN TEN TEN TEN /* 4090 */