https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69967

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> Yes, IPA (symtab) code warns about this and it doesn't push/pop warning
> options.
> In fact for global variables there are no saved options at all.

I don't think that matters. The pragmas only look at the locations, and they
are aware of the include/macro stack, so if the location is within the range,
it should work. This testcase works for me:

/* test.c */
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wunused-variable"
#include "test.h"
#pragma GCC diagnostic pop
void foo()
{
}
/* test.h */
static int x;

$ ~/test1/230753/build/gcc/cc1plus -Wall -Wextra test.c 
In file included from test.c:3:0:
test.h: At global scope:
test.h:1:12: error: ‘x’ defined but not used [-Werror=unused-variable]
 static int x;
            ^

I'm pretty sure that this was a warning introduced for 'static const' (it
appears in GCC 5.1 and disappears in GCC 6.1), and it seems it was using %q+ to
set the location implicitly, which breaks the pragmas.

Every use of '+' to set locations implicitly is a potential bug. Paolo removed
a lot of them from the C++ FE, but some may remain in the middle-end and
elsewhere.

Reply via email to