* RFA: let __extension__ suppress overlength string warning
@ 2011-01-18 18:36 Tom Tromey
2011-01-25 23:53 ` Joseph S. Myers
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2011-01-18 18:36 UTC (permalink / raw)
To: gcc-patches
SystemTap has some macros that can cause long strings to be generated.
See:
http://sourceware.org/bugzilla/show_bug.cgi?id=12137
The usual system header exception does not suppress the
overlength-string warning here because the string results from a macro
expansion. While Dodji's pending patch series promises to be able to
fix this, it seemed to me that __extension__ should also be able to do
this directly.
This patch changes the C parser to suppress the -Woverlength-strings
warning when the string is preceded by __extension__.
Built and regtested on x86-64 (compile farm).
New tests included.
Ok?
If approved, I assume I need to wait for stage 1 to commit this.
Tom
2011-01-18 Tom Tromey <tromey@redhat.com>
* c-parser.c (disable_extension_diagnostics): Save
warn_overlength_strings.
(restore_extension_diagnostics): Restore warn_overlength_strings.
2011-01-18 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.
Index: c-parser.c
===================================================================
--- c-parser.c (revision 168933)
+++ c-parser.c (working copy)
@@ -1045,13 +1045,15 @@
| (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 @@
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. */
Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c
===================================================================
--- testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0)
+++ testsuite/gcc.dg/Woverlength-strings-pedantic-c89-ext.c (revision 0)
@@ -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";
Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c
===================================================================
--- testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0)
+++ testsuite/gcc.dg/Woverlength-strings-pedantic-c90-ext.c (revision 0)
@@ -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";
Index: testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c
===================================================================
--- testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0)
+++ testsuite/gcc.dg/Woverlength-strings-pedantic-c99-ext.c (revision 0)
@@ -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";
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFA: let __extension__ suppress overlength string warning
2011-01-18 18:36 RFA: let __extension__ suppress overlength string warning Tom Tromey
@ 2011-01-25 23:53 ` Joseph S. Myers
2011-03-14 17:54 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Joseph S. Myers @ 2011-01-25 23:53 UTC (permalink / raw)
To: Tom Tromey; +Cc: gcc-patches
On Tue, 18 Jan 2011, Tom Tromey wrote:
> 2011-01-18 Tom Tromey <tromey@redhat.com>
>
> * c-parser.c (disable_extension_diagnostics): Save
> warn_overlength_strings.
> (restore_extension_diagnostics): Restore warn_overlength_strings.
>
> 2011-01-18 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.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFA: let __extension__ suppress overlength string warning
2011-01-25 23:53 ` Joseph S. Myers
@ 2011-03-14 17:54 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2011-03-14 17:54 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches
>> 2011-01-18 Tom Tromey <tromey@redhat.com>
>>
>> * c-parser.c (disable_extension_diagnostics): Save
>> warn_overlength_strings.
>> (restore_extension_diagnostics): Restore warn_overlength_strings.
>>
>> 2011-01-18 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.
Joseph> OK.
Now that Stage 1 is open, I am checking this in.
I think this is minor enough that it need not be synchronized with any
other commit.
Tom
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-14 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 18:36 RFA: let __extension__ suppress overlength string warning Tom Tromey
2011-01-25 23:53 ` Joseph S. Myers
2011-03-14 17:54 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).