diff mbox

Fix up _Pragma GCC diagnostics regressions (PR preprocessor/69543, PR c/69558)

Message ID 20160129195029.GV3017@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 29, 2016, 7:50 p.m. UTC
Hi!

This patch reverts one tiny change from r228049 changes (which hasn't been
mentioned in the ChangeLog or patch description).  We definitely need to
revisit this for GCC 7, but stage4 is probably not the right time for that,
and the patch fixes e.g. tons of warnings (or with -Werror errors on
including pretty much all glib2 headers).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/69543
	PR c/69558
	* c-pragma.c (handle_pragma_diagnostic): Pass input_location
	instead of loc to control_warning_option.

	* gcc.dg/pr69543.c: New test.
	* gcc.dg/pr69558.c: New test.


	Jakub

Comments

David Malcolm Jan. 30, 2016, 5:57 a.m. UTC | #1
On Fri, 2016-01-29 at 20:50 +0100, Jakub Jelinek wrote:
> Hi!
> 
> This patch reverts one tiny change from r228049 changes (which hasn't
> been
> mentioned in the ChangeLog or patch description).  We definitely need
> to
> revisit this for GCC 7, but stage4 is probably not the right time for
> that,
> and the patch fixes e.g. tons of warnings (or with -Werror errors on
> including pretty much all glib2 headers).
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2016-01-29  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR preprocessor/69543
> 	PR c/69558
> 	* c-pragma.c (handle_pragma_diagnostic): Pass input_location
> 	instead of loc to control_warning_option.
> 
> 	* gcc.dg/pr69543.c: New test.
> 	* gcc.dg/pr69558.c: New test.

This touches c-family; shouldn't the new tests be in c-c++-common,
rather than gcc.dg? (presumably we need to ensure that the glib2
headers are sane from C++ also)

I've been attempting to fix these by fixing linemap_compare_locations,
but I don't have that approach working, so fwiw I don't object to this
patch.
Jakub Jelinek Jan. 30, 2016, 9:38 a.m. UTC | #2
On Sat, Jan 30, 2016 at 06:57:48AM +0100, David Malcolm wrote:
> On Fri, 2016-01-29 at 20:50 +0100, Jakub Jelinek wrote:
> > Hi!
> > 
> > This patch reverts one tiny change from r228049 changes (which hasn't
> > been
> > mentioned in the ChangeLog or patch description).  We definitely need
> > to
> > revisit this for GCC 7, but stage4 is probably not the right time for
> > that,
> > and the patch fixes e.g. tons of warnings (or with -Werror errors on
> > including pretty much all glib2 headers).
> > 
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > 
> > 2016-01-29  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR preprocessor/69543
> > 	PR c/69558
> > 	* c-pragma.c (handle_pragma_diagnostic): Pass input_location
> > 	instead of loc to control_warning_option.
> > 
> > 	* gcc.dg/pr69543.c: New test.
> > 	* gcc.dg/pr69558.c: New test.
> 
> This touches c-family; shouldn't the new tests be in c-c++-common,
> rather than gcc.dg? (presumably we need to ensure that the glib2
> headers are sane from C++ also)

Ideally yes.  But they don't really work.
pr69558.c in C++ (i.e. glib2) doesn't look to be a regression, at least
those pragmas are supported in 4.6+ (and used in glib2 only for 4.6+) and
4.6 (don't have 4.7 around), 4.8, 4.9 and 5.3 all print two! warnings
about deprecated foo, and so does trunk g++, unpatched and patched.
So we actually have two bugs there, one is that we emit two warnings
instead of one (one is from mark_used called from somewhere, another
build_over_call), and another that we don't suppress the warning in C++,
but neither of them is a regression.
pr69543.c also fails in C++, and that is a regression.

> I've been attempting to fix these by fixing linemap_compare_locations,
> but I don't have that approach working, so fwiw I don't object to this
> patch.

	Jakub
Jeff Law Feb. 1, 2016, 10:21 p.m. UTC | #3
On 01/29/2016 10:57 PM, David Malcolm wrote:
> On Fri, 2016-01-29 at 20:50 +0100, Jakub Jelinek wrote:
>> Hi!
>>
>> This patch reverts one tiny change from r228049 changes (which hasn't
>> been
>> mentioned in the ChangeLog or patch description).  We definitely need
>> to
>> revisit this for GCC 7, but stage4 is probably not the right time for
>> that,
>> and the patch fixes e.g. tons of warnings (or with -Werror errors on
>> including pretty much all glib2 headers).
>>
>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>>
>> 2016-01-29  Jakub Jelinek  <jakub@redhat.com>
>>
>> 	PR preprocessor/69543
>> 	PR c/69558
>> 	* c-pragma.c (handle_pragma_diagnostic): Pass input_location
>> 	instead of loc to control_warning_option.
>>
>> 	* gcc.dg/pr69543.c: New test.
>> 	* gcc.dg/pr69558.c: New test.
>
> This touches c-family; shouldn't the new tests be in c-c++-common,
> rather than gcc.dg? (presumably we need to ensure that the glib2
> headers are sane from C++ also)
>
> I've been attempting to fix these by fixing linemap_compare_locations,
> but I don't have that approach working, so fwiw I don't object to this
> patch.
Then let's go ahead with this patch.  If you come up with something 
cleaner with the linemap_compare_locations, then we can revert the 
c-pragma part of this change (keeping the tests, of course).

jeff
diff mbox

Patch

--- gcc/c-family/c-pragma.c.jj	2016-01-15 21:57:00.000000000 +0100
+++ gcc/c-family/c-pragma.c	2016-01-29 18:34:51.743943283 +0100
@@ -817,9 +817,12 @@  handle_pragma_diagnostic(cpp_reader *ARG
   const char *arg = NULL;
   if (cl_options[option_index].flags & CL_JOINED)
     arg = option_string + 1 + cl_options[option_index].opt_len;
+  /* FIXME: input_location isn't the best location here, but it is
+     what we used to do here before and changing it breaks e.g.
+     PR69543 and PR69558.  */
   control_warning_option (option_index, (int) kind,
 			  arg, kind != DK_IGNORED,
-			  loc, lang_mask, &handlers,
+			  input_location, lang_mask, &handlers,
 			  &global_options, &global_options_set,
 			  global_dc);
 }
--- gcc/testsuite/gcc.dg/pr69558.c.jj	2016-01-29 18:43:32.191665058 +0100
+++ gcc/testsuite/gcc.dg/pr69558.c	2016-01-29 18:40:05.000000000 +0100
@@ -0,0 +1,17 @@ 
+/* PR c/69558 */
+/* { dg-do compile } */
+/* { dg-options "-Wdeprecated-declarations" } */
+
+#define A \
+  _Pragma ("GCC diagnostic push") \
+  _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define B \
+  _Pragma ("GCC diagnostic pop")
+#define C(x) \
+  A \
+  static inline void bar (void) { x (); } \
+  B
+
+__attribute__((deprecated)) void foo (void); /* { dg-bogus "declared here" } */
+
+C (foo) /* { dg-bogus "is deprecated" } */
--- gcc/testsuite/gcc.dg/pr69543.c.jj	2016-01-29 18:45:09.520323395 +0100
+++ gcc/testsuite/gcc.dg/pr69543.c	2016-01-29 18:44:56.000000000 +0100
@@ -0,0 +1,18 @@ 
+/* PR preprocessor/69543 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+    _Pragma ("GCC diagnostic push") \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+    _Pragma ("GCC diagnostic pop")
+
+void test (char yylval)
+{
+  char *yyvsp;
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+  *++yyvsp = yylval;
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
+}