diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-11-14 09:12:10 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-14 09:12:10 +0100 |
commit | b2417b59d4be2e5e882dec5ae3b373f69331d6e2 (patch) | |
tree | b3d7af488c90ecd3476ef6b9d1f9e4cbfc00051b /gcc/c/c-parser.c | |
parent | f14713178d25db56903458432b0e3dbf35dbe840 (diff) | |
download | gcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.zip gcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.tar.gz gcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.tar.bz2 |
omp-general.c (omp_context_name_list_prop): New function.
* omp-general.c (omp_context_name_list_prop): New function.
(omp_context_selector_matches): Use it. Return 0 if it returns
NULL.
(omp_context_selector_props_compare): Allow equivalency of an
identifier and a string literal containing no embedded zeros.
c-family/
* c-omp.c (c_omp_check_context_selector): Handle name lists
containing string literals. Don't diagnose atomic_default_mem_order
with multiple props.
c/
* c-parser.c (c_parser_omp_context_selector): Rename
CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID.
Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single
identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers
and string literals.
cp/
* parser.c (cp_parser_omp_context_selector): Rename
CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID.
Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single
identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers
and string literals.
* pt.c (tsubst_attribute): Fix up STRING_CST handling if allow_string.
testsuite/
* c-c++-common/gomp/declare-variant-2.c: Adjust expected diagnostics,
add a test for atomic_default_mem_order with a string literal.
* c-c++-common/gomp/declare-variant-3.c: Use string literal props
in a few random places, add a few string literal prop related tests.
* c-c++-common/gomp/declare-variant-8.c: Likewise.
* c-c++-common/gomp/declare-variant-9.c: Use string literal props
in a few random places.
* c-c++-common/gomp/declare-variant-10.c: Likewise.
* c-c++-common/gomp/declare-variant-11.c: Likewise.
* c-c++-common/gomp/declare-variant-12.c: Likewise.
* g++.dg/gomp/declare-variant-7.C: Likewise.
From-SVN: r278202
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r-- | gcc/c/c-parser.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 5f8695c..7219fc4 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -19728,9 +19728,9 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) bool allow_score = true; bool allow_user = false; int property_limit = 0; - enum { CTX_PROPERTY_NONE, CTX_PROPERTY_USER, CTX_PROPERTY_IDLIST, - CTX_PROPERTY_EXPR, CTX_PROPERTY_SIMD } property_kind - = CTX_PROPERTY_NONE; + enum { CTX_PROPERTY_NONE, CTX_PROPERTY_USER, CTX_PROPERTY_NAME_LIST, + CTX_PROPERTY_ID, CTX_PROPERTY_EXPR, + CTX_PROPERTY_SIMD } property_kind = CTX_PROPERTY_NONE; switch (IDENTIFIER_POINTER (set)[0]) { case 'c': /* construct */ @@ -19744,13 +19744,13 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) allow_score = false; allow_user = true; property_limit = 3; - property_kind = CTX_PROPERTY_IDLIST; + property_kind = CTX_PROPERTY_NAME_LIST; break; case 'i': /* implementation */ selectors = omp_implementation_selectors; allow_user = true; property_limit = 3; - property_kind = CTX_PROPERTY_IDLIST; + property_kind = CTX_PROPERTY_NAME_LIST; break; case 'u': /* user */ selectors = omp_user_selectors; @@ -19784,6 +19784,11 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) if (strcmp (selectors[i], IDENTIFIER_POINTER (selector)) == 0) break; } + if (property_kind == CTX_PROPERTY_NAME_LIST + && IDENTIFIER_POINTER (set)[0] == 'i' + && strcmp (IDENTIFIER_POINTER (selector), + "atomic_default_mem_order") == 0) + property_kind = CTX_PROPERTY_ID; c_parser_consume_token (parser); @@ -19859,21 +19864,41 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) } while (1); break; - case CTX_PROPERTY_IDLIST: + case CTX_PROPERTY_ID: + if (c_parser_next_token_is (parser, CPP_KEYWORD) + || c_parser_next_token_is (parser, CPP_NAME)) + { + tree prop = c_parser_peek_token (parser)->value; + c_parser_consume_token (parser); + properties = tree_cons (prop, NULL_TREE, properties); + } + else + { + c_parser_error (parser, "expected identifier"); + return error_mark_node; + } + break; + case CTX_PROPERTY_NAME_LIST: do { - tree prop; + tree prop = NULL_TREE, value = NULL_TREE; if (c_parser_next_token_is (parser, CPP_KEYWORD) || c_parser_next_token_is (parser, CPP_NAME)) - prop = c_parser_peek_token (parser)->value; + { + prop = c_parser_peek_token (parser)->value; + c_parser_consume_token (parser); + } + else if (c_parser_next_token_is (parser, CPP_STRING)) + value = c_parser_string_literal (parser, false, + false).value; else { - c_parser_error (parser, "expected identifier"); + c_parser_error (parser, "expected identifier or " + "string literal"); return error_mark_node; } - c_parser_consume_token (parser); - properties = tree_cons (prop, NULL_TREE, properties); + properties = tree_cons (prop, value, properties); if (c_parser_next_token_is (parser, CPP_COMMA)) c_parser_consume_token (parser); @@ -19923,7 +19948,8 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) parens.skip_until_found_close (parser); properties = nreverse (properties); } - else if (property_kind == CTX_PROPERTY_IDLIST + else if (property_kind == CTX_PROPERTY_NAME_LIST + || property_kind == CTX_PROPERTY_ID || property_kind == CTX_PROPERTY_EXPR) { c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"); |