From b2417b59d4be2e5e882dec5ae3b373f69331d6e2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 14 Nov 2019 09:12:10 +0100 Subject: [PATCH] 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 --- gcc/ChangeLog | 8 +++ gcc/c-family/ChangeLog | 6 ++ gcc/c-family/c-omp.c | 36 ++++++------ gcc/c/ChangeLog | 8 +++ gcc/c/c-parser.c | 50 ++++++++++++---- gcc/cp/ChangeLog | 9 +++ gcc/cp/parser.c | 49 ++++++++++++---- gcc/cp/pt.c | 4 +- gcc/omp-general.c | 58 +++++++++++++++++-- gcc/testsuite/ChangeLog | 14 +++++ .../c-c++-common/gomp/declare-variant-10.c | 6 +- .../c-c++-common/gomp/declare-variant-11.c | 10 ++-- .../c-c++-common/gomp/declare-variant-12.c | 4 +- .../c-c++-common/gomp/declare-variant-2.c | 16 ++--- .../c-c++-common/gomp/declare-variant-3.c | 26 +++++---- .../c-c++-common/gomp/declare-variant-8.c | 12 +++- .../c-c++-common/gomp/declare-variant-9.c | 10 ++-- gcc/testsuite/g++.dg/gomp/declare-variant-7.C | 2 +- 18 files changed, 243 insertions(+), 85 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfb88e67c8c..7da3e6df487 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-11-14 Jakub Jelinek + + * 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. + 2019-11-14 Aldy Hernandez * range-op.cc (RANGE3): Remove. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e96ed631f52..682355d4454 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2019-11-14 Jakub Jelinek + + * c-omp.c (c_omp_check_context_selector): Handle name lists + containing string literals. Don't diagnose atomic_default_mem_order + with multiple props. + 2019-11-13 Joseph Myers * c-cppbuiltin.c (builtin_define_float_constants): Also define diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index e53461dacf9..7d8eb322482 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2196,8 +2196,9 @@ c_omp_check_context_selector (location_t loc, tree ctx) { if (props[i].props[j] == NULL) { - if (!strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), - " score")) + if (TREE_PURPOSE (t2) + && !strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), + " score")) break; if (props[i].props == atomic_default_mem_order) { @@ -2207,31 +2208,28 @@ c_omp_check_context_selector (location_t loc, tree ctx) "atomic_default_mem_order"); return error_mark_node; } - else + else if (TREE_PURPOSE (t2)) warning_at (loc, 0, "unknown property %qs of %qs selector", IDENTIFIER_POINTER (TREE_PURPOSE (t2)), props[i].selector); + else + warning_at (loc, 0, + "unknown property %qE of %qs selector", + TREE_VALUE (t2), props[i].selector); break; } - else if (!strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), - props[i].props[j])) + else if (TREE_PURPOSE (t2) == NULL_TREE) { - if (props[i].props == atomic_default_mem_order - && t2 != TREE_VALUE (t1)) - { - tree t3 = TREE_VALUE (t1); - if (!strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t3)), - " score") - && t2 == TREE_CHAIN (TREE_VALUE (t1))) - break; - error_at (loc, - "%qs selector must have a single property", - "atomic_default_mem_order"); - return error_mark_node; - } - break; + const char *str = TREE_STRING_POINTER (TREE_VALUE (t2)); + if (!strcmp (str, props[i].props[j]) + && ((size_t) TREE_STRING_LENGTH (TREE_VALUE (t2)) + == strlen (str) + 1)) + break; } + else if (!strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), + props[i].props[j])) + break; } } return ctx; diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 228ebd8b17e..b60c6482993 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2019-11-14 Jakub Jelinek + + * 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. + 2019-11-14 Joseph Myers * c-tree.h (enum c_typespec_kind): Add ctsk_tagref_attrs and diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 5f8695c9d43..7219fc4f982 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 %<(%>"); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5c9c9f1a7bf..ec053f3933f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2019-11-14 Jakub Jelinek + + * 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. + 2019-11-13 Marek Polacek PR c++/89070 - bogus [[nodiscard]] warning in SFINAE. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f2fa7e83952..be29a2782c1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -40464,9 +40464,9 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) 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 */ @@ -40480,13 +40480,13 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) 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; @@ -40519,6 +40519,11 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) 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; cp_lexer_consume_token (parser->lexer); @@ -40607,21 +40612,40 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) } while (1); break; - case CTX_PROPERTY_IDLIST: + case CTX_PROPERTY_ID: + if (cp_lexer_next_token_is (parser->lexer, CPP_KEYWORD) + || cp_lexer_next_token_is (parser->lexer, CPP_NAME)) + { + tree prop = cp_lexer_peek_token (parser->lexer)->u.value; + cp_lexer_consume_token (parser->lexer); + properties = tree_cons (prop, NULL_TREE, properties); + } + else + { + cp_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 (cp_lexer_next_token_is (parser->lexer, CPP_KEYWORD) || cp_lexer_next_token_is (parser->lexer, CPP_NAME)) - prop = cp_lexer_peek_token (parser->lexer)->u.value; + { + prop = cp_lexer_peek_token (parser->lexer)->u.value; + cp_lexer_consume_token (parser->lexer); + } + else if (cp_lexer_next_token_is (parser->lexer, CPP_STRING)) + value = cp_parser_string_literal (parser, false, false); else { - cp_parser_error (parser, "expected identifier"); + cp_parser_error (parser, "expected identifier or " + "string literal"); return error_mark_node; } - cp_lexer_consume_token (parser->lexer); - properties = tree_cons (prop, NULL_TREE, properties); + properties = tree_cons (prop, value, properties); if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) cp_lexer_consume_token (parser->lexer); @@ -40668,7 +40692,8 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p) 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) { cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5a0efaa86c8..307ae6ee171 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11166,9 +11166,9 @@ tsubst_attribute (tree t, tree *decl_p, tree args, bool allow_string = ((TREE_PURPOSE (t2) != condition || set[0] != 'u') && TREE_PURPOSE (t3) != score); - if (TREE_CODE (t3) == STRING_CST && allow_string) - continue; tree v = TREE_VALUE (t3); + if (TREE_CODE (v) == STRING_CST && allow_string) + continue; v = tsubst_expr (v, args, complain, in_decl, true); v = fold_non_dependent_expr (v); if (!INTEGRAL_TYPE_P (TREE_TYPE (v)) diff --git a/gcc/omp-general.c b/gcc/omp-general.c index fd074a36b23..67ed345af90 100644 --- a/gcc/omp-general.c +++ b/gcc/omp-general.c @@ -652,6 +652,23 @@ omp_maybe_offloaded (void) return false; } +/* Return a name from PROP, a property in selectors accepting + name lists. */ + +static const char * +omp_context_name_list_prop (tree prop) +{ + if (TREE_PURPOSE (prop)) + return IDENTIFIER_POINTER (TREE_PURPOSE (prop)); + else + { + const char *ret = TREE_STRING_POINTER (TREE_VALUE (prop)); + if ((size_t) TREE_STRING_LENGTH (TREE_VALUE (prop)) == strlen (ret) + 1) + return ret; + return NULL; + } +} + /* Return 1 if context selector matches the current OpenMP context, 0 if it does not and -1 if it is unknown and need to be determined later. Some properties can be checked right away during parsing (this routine), @@ -701,8 +718,11 @@ omp_context_selector_matches (tree ctx) if (set == 'i' && !strcmp (sel, "vendor")) for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3)) { - const char *prop = IDENTIFIER_POINTER (TREE_PURPOSE (t3)); - if (!strcmp (prop, " score") || !strcmp (prop, "gnu")) + const char *prop = omp_context_name_list_prop (t3); + if (prop == NULL) + return 0; + if ((!strcmp (prop, " score") && TREE_PURPOSE (t3)) + || !strcmp (prop, "gnu")) continue; return 0; } @@ -750,7 +770,9 @@ omp_context_selector_matches (tree ctx) if (set == 'd' && !strcmp (sel, "arch")) for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3)) { - const char *arch = IDENTIFIER_POINTER (TREE_PURPOSE (t3)); + const char *arch = omp_context_name_list_prop (t3); + if (arch == NULL) + return 0; int r = 0; if (targetm.omp.device_kind_arch_isa != NULL) r = targetm.omp.device_kind_arch_isa (omp_device_arch, @@ -844,7 +866,9 @@ omp_context_selector_matches (tree ctx) if (set == 'd' && !strcmp (sel, "kind")) for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3)) { - const char *prop = IDENTIFIER_POINTER (TREE_PURPOSE (t3)); + const char *prop = omp_context_name_list_prop (t3); + if (prop == NULL) + return 0; if (!strcmp (prop, "any")) continue; if (!strcmp (prop, "host")) @@ -903,7 +927,9 @@ omp_context_selector_matches (tree ctx) if (set == 'd' && !strcmp (sel, "isa")) for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3)) { - const char *isa = IDENTIFIER_POINTER (TREE_PURPOSE (t3)); + const char *isa = omp_context_name_list_prop (t3); + if (isa == NULL) + return 0; int r = 0; if (targetm.omp.device_kind_arch_isa != NULL) r = targetm.omp.device_kind_arch_isa (omp_device_isa, @@ -1109,6 +1135,28 @@ omp_context_selector_props_compare (const char *set, const char *sel, else break; } + else if (TREE_PURPOSE (t1) + && TREE_PURPOSE (t2) == NULL_TREE + && TREE_CODE (TREE_VALUE (t2)) == STRING_CST) + { + const char *p1 = omp_context_name_list_prop (t1); + const char *p2 = omp_context_name_list_prop (t2); + if (p2 + && strcmp (p1, p2) == 0 + && strcmp (p1, " score")) + break; + } + else if (TREE_PURPOSE (t1) == NULL_TREE + && TREE_PURPOSE (t2) + && TREE_CODE (TREE_VALUE (t1)) == STRING_CST) + { + const char *p1 = omp_context_name_list_prop (t1); + const char *p2 = omp_context_name_list_prop (t2); + if (p1 + && strcmp (p1, p2) == 0 + && strcmp (p1, " score")) + break; + } if (t2 == NULL_TREE) { int r = pass ? -1 : 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce2ec9a68d0..2b32bd28f38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2019-11-14 Jakub Jelinek + + * 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. + 2019-11-14 Kewen Lin PR target/92464 diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c index ad886cfb887..2b8a39425b1 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c @@ -7,7 +7,7 @@ void f01 (void); #pragma omp declare variant (f01) match (device={isa(avx512f,avx512bw)}) void f02 (void); void f03 (void); -#pragma omp declare variant (f03) match (device={kind(any),arch(x86_64),isa(avx512f,avx512bw)}) +#pragma omp declare variant (f03) match (device={kind("any"),arch(x86_64),isa(avx512f,avx512bw)}) void f04 (void); void f05 (void); #pragma omp declare variant (f05) match (device={kind(gpu)}) @@ -19,10 +19,10 @@ void f09 (void); #pragma omp declare variant (f09) match (device={isa(sm_35)}) void f10 (void); void f11 (void); -#pragma omp declare variant (f11) match (device={arch(nvptx)}) +#pragma omp declare variant (f11) match (device={arch("nvptx")}) void f12 (void); void f13 (void); -#pragma omp declare variant (f13) match (device={arch(i386),isa(sse4)}) +#pragma omp declare variant (f13) match (device={arch(i386),isa("sse4")}) void f14 (void); void f15 (void); #pragma omp declare variant (f15) match (device={isa(sse4,ssse3),arch(i386)}) diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-11.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-11.c index 9879a9b5da5..9589948a0f7 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-11.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-11.c @@ -4,8 +4,8 @@ void f01 (void); void f02 (void); -#pragma omp declare variant (f01) match (device={isa(avx512f,avx512vl)}) -#pragma omp declare variant (f02) match (device={isa(avx512bw,avx512vl,avx512f)}) +#pragma omp declare variant (f01) match (device={isa(avx512f,"avx512vl")}) +#pragma omp declare variant (f02) match (device={isa(avx512bw,avx512vl,"avx512f")}) void f03 (void); void f04 (void); void f05 (void); @@ -14,13 +14,13 @@ void f05 (void); void f06 (void); void f07 (void); void f08 (void); -#pragma omp declare variant (f07) match (device={isa(sse4,sse3,avx)}) -#pragma omp declare variant (f08) match (device={isa(avx,sse3)}) +#pragma omp declare variant (f07) match (device={isa(sse4,sse3,"avx")}) +#pragma omp declare variant (f08) match (device={isa("avx",sse3)}) void f09 (void); void f10 (void); void f11 (void); void f12 (void); -#pragma omp declare variant (f10) match (device={isa(avx512f)}) +#pragma omp declare variant (f10) match (device={isa("avx512f")}) #pragma omp declare variant (f11) match (user={condition(1)},device={isa(avx512f)},implementation={vendor(gnu)}) #pragma omp declare variant (f12) match (user={condition(2 + 1)},device={isa(avx512f)}) void f13 (void); diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-12.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-12.c index f01c757c08d..3515d9ae44e 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-12.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-12.c @@ -6,7 +6,7 @@ void f01 (void); void f02 (void); void f03 (void); -#pragma omp declare variant (f01) match (device={isa(avx512f,avx512vl)}) /* 16 */ +#pragma omp declare variant (f01) match (device={isa("avx512f","avx512vl")}) /* 16 */ #pragma omp declare variant (f02) match (implementation={vendor(score(15):gnu)}) #pragma omp declare variant (f03) match (user={condition(score(11):1)}) void f04 (void); @@ -22,7 +22,7 @@ void f10 (void); void f11 (void); void f12 (void); #pragma omp declare variant (f09) match (device={arch(x86_64)},user={condition(score(65):1)}) /* 64+65 */ -#pragma omp declare variant (f10) match (implementation={vendor(score(127):gnu)}) +#pragma omp declare variant (f10) match (implementation={vendor(score(127):"gnu")}) #pragma omp declare variant (f11) match (device={isa(ssse3)}) /* 128 */ #pragma omp declare variant (f12) match (implementation={atomic_default_mem_order(score(126):seq_cst)}) void f13 (void); diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c index 1a16a9904e3..949a239aa91 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c @@ -69,15 +69,15 @@ void f33 (void); void f34 (void); #pragma omp declare variant (f1) match(device={kind,isa,arch}) /* { dg-error "expected '\\(' before ',' token" } */ void f35 (void); -#pragma omp declare variant (f1) match(device={kind(}) /* { dg-error "expected identifier before '\\\}' token" } */ +#pragma omp declare variant (f1) match(device={kind(}) /* { dg-error "expected identifier or string literal before '\\\}' token" } */ void f36 (void); #pragma omp declare variant (f1) match(device={kind(unknown)}) /* { dg-warning "unknown property 'unknown' of 'kind' selector" } */ void f37 (void); #pragma omp declare variant (f1) match(device={kind(unknown,foobar)}) /* { dg-warning "unknown property 'unknown' of 'kind' selector" } */ void f38 (void); /* { dg-warning "unknown property 'foobar' of 'kind' selector" "" { target *-*-* } .-1 } */ -#pragma omp declare variant (f1) match(device={isa(1)}) /* { dg-error "expected identifier before numeric constant" } */ +#pragma omp declare variant (f1) match(device={isa(1)}) /* { dg-error "expected identifier or string literal before numeric constant" } */ void f39 (void); -#pragma omp declare variant (f1) match(device={arch(17)}) /* { dg-error "expected identifier before numeric constant" } */ +#pragma omp declare variant (f1) match(device={arch(17)}) /* { dg-error "expected identifier or string literal before numeric constant" } */ void f40 (void); #pragma omp declare variant (f1) match(device={foobar(3)}) void f41 (void); @@ -89,11 +89,11 @@ void f43 (void); void f44 (void); #pragma omp declare variant (f1) match(implementation={extension}) /* { dg-error "expected '\\(' before '\\\}' token" } */ void f45 (void); -#pragma omp declare variant (f1) match(implementation={vendor()}) /* { dg-error "expected identifier before '\\)' token" } */ +#pragma omp declare variant (f1) match(implementation={vendor()}) /* { dg-error "expected identifier or string literal before '\\)' token" } */ void f45 (void); -#pragma omp declare variant (f1) match(implementation={vendor(123-234)}) /* { dg-error "expected identifier before numeric constant" } */ +#pragma omp declare variant (f1) match(implementation={vendor(123-234)}) /* { dg-error "expected identifier or string literal before numeric constant" } */ void f46 (void); -#pragma omp declare variant (f1) match(implementation={vendor("x86_64")}) /* { dg-error "expected identifier before string constant" } */ +#pragma omp declare variant (f1) match(implementation={vendor("foobar")}) /* { dg-warning "unknown property '.foobar.' of 'vendor' selector" } */ void f47 (void); #pragma omp declare variant (f1) match(implementation={unified_address(yes)}) /* { dg-error "selector 'unified_address' does not accept any properties" } */ void f48 (void); /* { dg-error "expected '\\\}' before '\\(' token" "" { target c } .-1 } */ @@ -111,7 +111,7 @@ void f53 (void); void f54 (void); #pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(foobar)}) /* { dg-error "incorrect property 'foobar' of 'atomic_default_mem_order' selector" } */ void f55 (void); -#pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(relaxed,seq_cst)}) /* { dg-error "'atomic_default_mem_order' selector must have a single property" } */ +#pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(relaxed,seq_cst)}) /* { dg-error "expected '\\)' before ',' token" } */ void f56 (void); #pragma omp declare variant (f1) match(implementation={atomic_default_mem_order(relaxed)},implementation={atomic_default_mem_order(relaxed)}) /* { dg-error "selector set 'implementation' specified more than once" } */ void f57 (void); @@ -151,3 +151,5 @@ void f73 (void); void f74 (void); #pragma omp declare variant (f1),match(construct={parallel}) /* { dg-error "expected 'match' before ','" } */ void f75 (void); +#pragma omp declare variant (f1) match(implementation={atomic_default_mem_order("relaxed")}) /* { dg-error "expected identifier before string constant" } */ +void f76 (void); diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c index 34a2a06db1b..e1c37a0b422 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c @@ -19,13 +19,13 @@ void f12 (void); void f13 (void); #pragma omp declare variant (f13) match (device={kind(any)}) void f14 (void); -#pragma omp declare variant (f13) match (device={kind(host)}) +#pragma omp declare variant (f13) match (device={kind("host")}) void f15 (void); #pragma omp declare variant (f13) match (device={kind(nohost)}) void f16 (void); #pragma omp declare variant (f13) match (device={kind(cpu)}) void f17 (void); -#pragma omp declare variant (f13) match (device={kind(gpu)}) +#pragma omp declare variant (f13) match (device={kind("gpu")}) void f18 (void); #pragma omp declare variant (f13) match (device={kind(fpga)}) void f19 (void); @@ -33,27 +33,27 @@ void f19 (void); void f20 (void); #pragma omp declare variant (f13) match (device={kind(host,nohost)}) void f21 (void); -#pragma omp declare variant (f13) match (device={kind(cpu,gpu,fpga)}) +#pragma omp declare variant (f13) match (device={kind("cpu","gpu","fpga")}) void f22 (void); #pragma omp declare variant (f13) match (device={kind(any,cpu,nohost)}) void f23 (void); #pragma omp declare variant (f13) match (device={isa(avx)}) void f24 (void); -#pragma omp declare variant (f13) match (device={isa(sse4,avx512f,avx512vl,avx512bw)}) +#pragma omp declare variant (f13) match (device={isa(sse4,"avx512f",avx512vl,avx512bw)}) void f25 (void); -#pragma omp declare variant (f13) match (device={arch(x86_64)}) +#pragma omp declare variant (f13) match (device={arch("x86_64")}) void f26 (void); #pragma omp declare variant (f13) match (device={arch(riscv64)}) void f27 (void); #pragma omp declare variant (f13) match (device={arch(nvptx)}) void f28 (void); -#pragma omp declare variant (f13) match (device={arch(x86_64),isa(avx512f,avx512vl),kind(cpu)}) +#pragma omp declare variant (f13) match (device={arch(x86_64),isa("avx512f","avx512vl"),kind(cpu)}) void f29 (void); #pragma omp declare variant (f13) match (implementation={vendor(amd)}) void f30 (void); #pragma omp declare variant (f13) match (implementation={vendor(arm)}) void f31 (void); -#pragma omp declare variant (f13) match (implementation={vendor(bsc)}) +#pragma omp declare variant (f13) match (implementation={vendor("bsc")}) void f32 (void); #pragma omp declare variant (f13) match (implementation={vendor(cray)}) void f33 (void); @@ -63,7 +63,7 @@ void f34 (void); void f35 (void); #pragma omp declare variant (f13) match (implementation={vendor(ibm)}) void f36 (void); -#pragma omp declare variant (f13) match (implementation={vendor(intel)}) +#pragma omp declare variant (f13) match (implementation={vendor("intel")}) void f37 (void); #pragma omp declare variant (f13) match (implementation={vendor(llvm)}) void f38 (void); @@ -97,7 +97,7 @@ void f51 (void); void f52 (void); #pragma omp declare variant (f13) match (implementation={vendor(score(3):amd)}) void f53 (void); -#pragma omp declare variant (f13) match (implementation={vendor(score(4):arm)}) +#pragma omp declare variant (f13) match (implementation={vendor(score(4):"arm")}) void f54 (void); #pragma omp declare variant (f13) match (implementation={vendor(score(5):bsc)}) void f55 (void); @@ -115,7 +115,7 @@ void f60 (void); void f61 (void); #pragma omp declare variant (f13) match (implementation={vendor(score(12):pgi)}) void f62 (void); -#pragma omp declare variant (f13) match (implementation={vendor(score(13):ti)}) +#pragma omp declare variant (f13) match (implementation={vendor(score(13):"ti")}) void f63 (void); #pragma omp declare variant (f13) match (implementation={vendor(score(14):unknown)}) void f64 (void); @@ -139,3 +139,9 @@ void f72 (void); void f73 (void); #pragma omp declare variant (f13) match (user={condition(score(25):1)}) void f74 (void); +#pragma omp declare variant (f13) match (device={kind(any,"any")}) +void f75 (void); +#pragma omp declare variant (f13) match (device={kind("any","any")}) +void f76 (void); +#pragma omp declare variant (f13) match (device={kind("any",any)}) +void f77 (void); diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-8.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-8.c index 792e56ccd97..a7a3ba41b97 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-8.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-8.c @@ -12,10 +12,10 @@ void f05 (void); void f06 (void); #pragma omp requires atomic_default_mem_order(seq_cst) void f07 (void); -#pragma omp declare variant (f07) match (construct={parallel,for},device={kind(any)}) +#pragma omp declare variant (f07) match (construct={parallel,for},device={kind("any")}) void f08 (void); void f09 (void); -#pragma omp declare variant (f09) match (construct={parallel,for},implementation={vendor(gnu)}) +#pragma omp declare variant (f09) match (construct={parallel,for},implementation={vendor("gnu")}) void f10 (void); void f11 (void); #pragma omp declare variant (f11) match (construct={parallel,for}) @@ -51,6 +51,12 @@ void f30 (void); void f31 (void); #pragma omp declare variant (f31) match (construct={teams,parallel,for}) void f32 (void); +void f33 (void); +#pragma omp declare variant (f33) match (device={kind("any\0any")}) /* { dg-warning "unknown property '.any.000any.' of 'kind' selector" } */ +void f34 (void); +void f35 (void); +#pragma omp declare variant (f35) match (implementation={vendor("gnu\0")}) /* { dg-warning "unknown property '.gnu.000.' of 'vendor' selector" } */ +void f36 (void); void test1 (void) @@ -76,6 +82,8 @@ test1 (void) for (i = 0; i < 1; i++) f14 (); /* { dg-final { scan-tree-dump-times "f14 \\\(\\\);" 1 "gimple" } } */ f16 (); /* { dg-final { scan-tree-dump-times "f16 \\\(\\\);" 1 "gimple" } } */ + f34 (); /* { dg-final { scan-tree-dump-times "f34 \\\(\\\);" 1 "gimple" } } */ + f36 (); /* { dg-final { scan-tree-dump-times "f36 \\\(\\\);" 1 "gimple" } } */ } #pragma omp declare target diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c index 21ddc56681b..5ee75892f2d 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c @@ -4,16 +4,16 @@ #undef i386 void f01 (void); -#pragma omp declare variant (f01) match (device={isa(avx512f,avx512bw)}) +#pragma omp declare variant (f01) match (device={isa("avx512f",avx512bw)}) void f02 (void); void f03 (void); -#pragma omp declare variant (f03) match (device={kind(any),arch(x86_64),isa(avx512f,avx512bw)}) +#pragma omp declare variant (f03) match (device={kind(any),arch(x86_64),isa("avx512f","avx512bw")}) void f04 (void); void f05 (void); #pragma omp declare variant (f05) match (device={kind(gpu)}) void f06 (void); void f07 (void); -#pragma omp declare variant (f07) match (device={kind(cpu)}) +#pragma omp declare variant (f07) match (device={kind("cpu")}) void f08 (void); void f09 (void); #pragma omp declare variant (f09) match (device={isa(sm_35)}) @@ -22,13 +22,13 @@ void f11 (void); #pragma omp declare variant (f11) match (device={arch(nvptx)}) void f12 (void); void f13 (void); -#pragma omp declare variant (f13) match (device={arch(i386),isa(sse4)}) +#pragma omp declare variant (f13) match (device={arch("i386"),isa(sse4)}) void f14 (void); void f15 (void); #pragma omp declare variant (f15) match (device={isa(sse4,ssse3),arch(i386)}) void f16 (void); void f17 (void); -#pragma omp declare variant (f17) match (device={kind(any,fpga)}) +#pragma omp declare variant (f17) match (device={kind("any","fpga")}) void f18 (void); void diff --git a/gcc/testsuite/g++.dg/gomp/declare-variant-7.C b/gcc/testsuite/g++.dg/gomp/declare-variant-7.C index 4a3e831bc29..7dda899578a 100644 --- a/gcc/testsuite/g++.dg/gomp/declare-variant-7.C +++ b/gcc/testsuite/g++.dg/gomp/declare-variant-7.C @@ -12,7 +12,7 @@ template void f04 (); template void f05 (); -#pragma omp declare variant (f05) match (user={condition((T)N)},implementation={vendor(gnu)}) +#pragma omp declare variant (f05) match (user={condition((T)N)},implementation={vendor("gnu")}) template void f06 (); void f07 (); -- 2.30.2