diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-10-12 10:27:36 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-10-12 10:27:36 +0200 |
commit | 20de9568b49e663be848a35ce0bb08f63f14b5b2 (patch) | |
tree | 302f44f3d609ab83db0ef9a7e4ec5aeb4287965e /gcc/c | |
parent | 47370f050940a2e140e89fc0d46e808fab206f04 (diff) | |
download | gcc-20de9568b49e663be848a35ce0bb08f63f14b5b2.zip gcc-20de9568b49e663be848a35ce0bb08f63f14b5b2.tar.gz gcc-20de9568b49e663be848a35ce0bb08f63f14b5b2.tar.bz2 |
c-common.h (c_omp_mark_declare_variant, [...]): Declare.
c-family/
* c-common.h (c_omp_mark_declare_variant,
c_omp_context_selector_matches): Declare.
* c-omp.c: Include attribs.h, gimplify.h, cgraph.h, symbol-summary.h
and hsa-common.h.
(c_omp_get_context_selector): Support second argument NULL.
(c_omp_mark_declare_variant, c_omp_context_selector_matches): New
functions.
* c-attribs.c (c_common_attribute_table): Remove "omp declare variant"
attribute, add "omp declare variant base" and
"omp declare variant variant" attributes.
c/
* c-parser.c (c_parser_omp_context_selector): Improve error recovery.
For simd properties, put them directly into TREE_VALUE.
(c_finish_omp_declare_variant): Call c_omp_mark_declare_variant.
If c_omp_context_selector_matches is 0, don't add attribute, otherwise
add "omp declare variant base" attribute rather than
"omp declare variant".
cp/
* parser.c (cp_parser_omp_context_selector): Improve error recovery.
For simd properties, put them directly into TREE_VALUE.
(cp_finish_omp_declare_variant): Add "omp declare variant base"
attribute rather than "omp declare variant".
testsuite/
* c-c++-common/gomp/declare-variant-2.c: Adjust for error recovery
improvements. Add new tests.
* c-c++-common/gomp/declare-variant-4.c: New test.
* c-c++-common/gomp/declare-variant-5.c: New test.
* c-c++-common/gomp/declare-variant-6.c: New test.
* c-c++-common/gomp/declare-variant-7.c: New test.
From-SVN: r276914
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 24 |
2 files changed, 26 insertions, 7 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 894f5e7..5fb386c 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2019-10-12 Jakub Jelinek <jakub@redhat.com> + + * c-parser.c (c_parser_omp_context_selector): Improve error recovery. + For simd properties, put them directly into TREE_VALUE. + (c_finish_omp_declare_variant): Call c_omp_mark_declare_variant. + If c_omp_context_selector_matches is 0, don't add attribute, otherwise + add "omp declare variant base" attribute rather than + "omp declare variant". + 2019-10-11 Joseph Myers <joseph@codesourcery.com> * c-decl.c (declspecs_add_type): Use pedwarn_c11 for DFP types. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 2daaee8..9d0b2b6 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -19219,6 +19219,8 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) else properties = tree_cons (NULL_TREE, t, properties); } + else + return error_mark_node; if (c_parser_next_token_is (parser, CPP_COMMA)) c_parser_consume_token (parser); @@ -19263,6 +19265,8 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) else properties = tree_cons (NULL_TREE, t, properties); } + else + return error_mark_node; break; case CTX_PROPERTY_SIMD: if (parms == NULL_TREE) @@ -19280,7 +19284,7 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms) == error_mark_node ? NULL_TREE : parms, c); - properties = tree_cons (NULL_TREE, c, properties); + properties = c; break; default: gcc_unreachable (); @@ -19389,7 +19393,7 @@ c_parser_omp_context_selector_specification (c_parser *parser, tree parms) } /* Finalize #pragma omp declare variant after FNDECL has been parsed, and put - that into "omp declare variant" attribute. */ + that into "omp declare variant base" attribute. */ static void c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) @@ -19473,10 +19477,16 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) if (variant != error_mark_node) { C_DECL_USED (variant) = 1; - tree attr = tree_cons (get_identifier ("omp declare variant"), - build_tree_list (variant, ctx), - DECL_ATTRIBUTES (fndecl)); - DECL_ATTRIBUTES (fndecl) = attr; + tree construct = c_omp_get_context_selector (ctx, "construct", NULL); + c_omp_mark_declare_variant (match_loc, variant, construct); + if (c_omp_context_selector_matches (ctx)) + { + tree attr + = tree_cons (get_identifier ("omp declare variant base"), + build_tree_list (variant, ctx), + DECL_ATTRIBUTES (fndecl)); + DECL_ATTRIBUTES (fndecl) = attr; + } } } @@ -19486,7 +19496,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) /* Finalize #pragma omp declare simd or #pragma omp declare variant clauses after FNDECL has been parsed, and put that into "omp declare simd" - or "omp declare variant" attribute. */ + or "omp declare variant base" attribute. */ static void c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, |