Hi Tom. Hi folks.
We've asked Balaji to rewrite the <#pragma simd> handling for cilkplus
as we currently do for OMP, etc, in init_pragma().
The cilkplus branch currently has something like:
cpp_register_deferred_pragma (parse_in, "simd", "",
PRAGMA_SIMD_EMPTY, true, false);
cpp_register_deferred_pragma (parse_in, "simd", "assert",
PRAGMA_SIMD_ASSERT, true, false);
cpp_register_deferred_pragma (parse_in, "simd", "noassert",
PRAGMA_SIMD_NOASSERT, true, false);
cpp_register_deferred_pragma (parse_in, "simd", "vectorlength",
PRAGMA_SIMD_VECTORLENGTH, true, false);
Notice that #pragma simd can be both a pragma name space, and also a
lone pragma with no arguments:
#pragma simd assert
-or-
#pragma simd
It seems like the code in libcpp's do_pragma(), specifically disallows
this. If we're looking at a possible pragma name space, the next
expected token is a CPP_NAME.
Is there a way to handle this scenario with the current infrastructure?
If not, is something like the attached (untested) patch reasonable?
Aldy
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 65b2034..d09d2a4 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1373,7 +1373,26 @@ do_pragma (cpp_reader *pfile)
if (token->type == CPP_NAME)
p = lookup_pragma_entry (p->u.space, token->val.node.node);
else
- p = NULL;
+ {
+ /* See if we can handle pragmas that are defined both as
+ a pragma namespace, and as an argumentless pragma.
+ For example:
+
+ #pragma simd vectorlength
+ #pragma simd // empty argument
+ */
+ if (token->type == CPP_EOF)
+ {
+ const cpp_hashnode *node;
+ node = cpp_lookup (pfile, UC "", 0);
+ if (node)
+ p = lookup_pragma_entry (p->u.space, node);
+ else
+ p = NULL;
+ }
+ else
+ p = NULL;
+ }
if (allow_name_expansion)
pfile->state.prevent_expansion++;
count = 2;