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
aclocal.m4 Undo inadvertent commit in rev 160105. 2010-06-01 10:20:24 -04:00
ChangeLog PR preprocessor/53469 - argument tokens of _Pragma miss virtual location 2012-08-27 17:41:38 +02:00
charset.c Update Copyright years for files modified in 2010. 2011-01-03 21:52:22 +01:00
config.in re PR bootstrap/45538 (--enable-build-with-cxx compiling gcc/libcpp/charset.c) 2010-11-18 07:35:34 +00:00
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 LINEMAP_POSITION_FOR_COLUMN had the exact same effect as linemap_position_for_column... 2011-08-15 20:35:58 +00:00
directives.c PR preprocessor/53469 - argument tokens of _Pragma miss virtual location 2012-08-27 17:41:38 +02:00
errors.c Update Copyright years for files modified in 2010. 2011-01-03 21:52:22 +01:00
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
Makefile.in backport: As described in http://gcc.gnu.org/ml/gcc/2012-08/msg00015.html... 2012-08-14 21:56:07 -04:00
makeucnid.c
mkdeps.c files.c (file_hash_eq): Use filename_cmp instead of strcmp. 2011-03-25 20:11:26 +01:00
pch.c remove useless if-before-free tests 2011-04-20 18:19:03 +00:00
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 Generate virtual locations for tokens 2011-10-17 11:59:12 +02:00
ucnid.h
ucnid.tab