aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-06-06 11:33:42 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-06-06 13:33:42 +0200
commit38fbfaf6fb23fdcd130cc524839686b9ad28f752 (patch)
tree3c306927913661e1e914dc99031a45c1684aaff8 /libcpp
parent3bfc61cf25241bdcf7aad08c1e2b6607d25f97bb (diff)
downloadgcc-38fbfaf6fb23fdcd130cc524839686b9ad28f752.zip
gcc-38fbfaf6fb23fdcd130cc524839686b9ad28f752.tar.gz
gcc-38fbfaf6fb23fdcd130cc524839686b9ad28f752.tar.bz2
re PR preprocessor/48532 (Wrong location of namespaced pragma involving macros)
PR preprocessor/48532 libcpp/ * directives.c (do_pragma): Don't forget the invocation location when parsing the pragma name of a namespaced pragma directive. gcc/testsuite/ * gcc.dg/cpp/pragma-3.c: New test case. From-SVN: r174694
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/directives.c31
2 files changed, 36 insertions, 1 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 485d66e..e1c01c1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-06 Dodji Seketeli <dodji@redhat.com>
+
+ PR preprocessor/48532
+ * directives.c (do_pragma): Don't forget the invocation location
+ when parsing the pragma name of a namespaced pragma directive.
+
2011-05-29 John Tytgat <John.Tytgat@aaug.net>
* files.c (read_file_guts): Add test on non-zero value of S_ISREG.
diff --git a/libcpp/directives.c b/libcpp/directives.c
index f244ae5..85e941e 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1360,7 +1360,36 @@ do_pragma (cpp_reader *pfile)
{
bool allow_name_expansion = p->allow_expansion;
if (allow_name_expansion)
- pfile->state.prevent_expansion--;
+ {
+ pfile->state.prevent_expansion--;
+ /*
+ Kludge ahead.
+
+ Consider this code snippet:
+
+ #define P parallel
+ #pragma omp P for
+ ... a for loop ...
+
+ Once we parsed the 'omp' namespace of the #pragma
+ directive, we then parse the 'P' token that represents the
+ pragma name. P being a macro, it is expanded into the
+ resulting 'parallel' token.
+
+ At this point the 'p' variable contains the 'parallel'
+ pragma name. And pfile->context->macro is non-null
+ because we are still right at the end of the macro
+ context of 'P'. The problem is, if we are being
+ (indirectly) called by cpp_get_token_with_location,
+ that function might test pfile->context->macro to see
+ if we are in the context of a macro expansion, (and we
+ are) and then use pfile->invocation_location as the
+ location of the macro invocation. So we must instruct
+ cpp_get_token below to set
+ pfile->invocation_location. */
+ pfile->set_invocation_location = true;
+ }
+
token = cpp_get_token (pfile);
if (token->type == CPP_NAME)
p = lookup_pragma_entry (p->u.space, token->val.node.node);