aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-06 11:33:42 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-06 11:33:42 +0000
commit2c694d44b2428673f2ec4177c57f6efda4c91adb (patch)
tree3c306927913661e1e914dc99031a45c1684aaff8 /libcpp/directives.c
parent06e10d4a71e4249784f6c0c39a814aefdd275f09 (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index f244ae5b5b2..85e941ed49c 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);