gcc/libcpp
Dodji Seketeli f3d25c6570 PR preprocessor/53469 - argument tokens of _Pragma miss virtual location
Consider this short test snippet:

-------------------------8-------------------
    #define STRINGIFY(x) #x
    #define TEST(x) \
      _Pragma(STRINGIFY(GCC diagnostic ignored "-Wunused-local-typedefs")) \
      typedef int myint;

    void bar ()
    {
      TEST(myint)
    }
-------------------------8-------------------

The _Pragma is effectively ignored, and compiling with
-Wunused-local-typedefs warns on the local typedef, even though the
pragma should have prevented the warning to be emitted.

This is because when the preprocessor sees the _Pragma operator and
then goes to handle the first token ('GCC' here) that makes up its
operands, it retains the spelling location of that token, not its
virtual location.

Later when diagnostic_report_diagnostic is called to emit the warning
(or ignore it because of the pragma), it compares the location of the
first operand of the pragma with the location of the unused location,
(by calling linemap_location_before_p) and that comparison fails
because in this case, both locations should be virtual.

This patch fixes the issue by teaching the pragma handling to use
virtual locations.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

libcpp/

	PR preprocessor/53469
	* directives.c (do_pragma): Use the virtual location for the
	pragma token, instead of its spelling location.

gcc/testsuite/

	PR preprocessor/53469
	* gcc.dg/cpp/_Pragma7.c: New test case.

From-SVN: r190714
2012-08-27 17:41:38 +02:00
..
include backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
po * cpplib.pot: Regenerate. 2012-06-13 22:48:00 +01:00
ChangeLog PR preprocessor/53469 - argument tokens of _Pragma miss virtual location 2012-08-27 17:41:38 +02:00
Makefile.in backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
aclocal.m4
charset.c
config.in
configure backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
configure.ac backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
directives-only.c
directives.c PR preprocessor/53469 - argument tokens of _Pragma miss virtual location 2012-08-27 17:41:38 +02:00
errors.c
expr.c PR preprocessor/7263 - Avoid pedantic warnings on system headers macro tokens 2012-05-16 12:51:15 +02:00
files.c re PR c++/52974 (Canonicalize include paths in diagnostics) 2012-04-30 16:57:22 +00:00
identifiers.c backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
init.c backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
internal.h backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
lex.c lex.c (search_line_sse42): Use __builtin_ia32_loaddqu and __builtin_ia32_pcmpestri128 instead of asm. 2012-06-19 18:28:50 +02:00
line-map.c line-map.c (linemap_enter_macro): Don't zero max_column_hint in every macro. 2012-06-05 10:25:46 -04:00
macro.c directives.c: Fix typos. 2012-05-29 15:53:50 +01:00
makeucnid.c
mkdeps.c
pch.c
symtab.c backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
system.h system.h: Prior to #define, #undef fopen and freopen unconditionally. 2012-01-03 11:44:34 +00:00
traditional.c
ucnid.h
ucnid.tab