diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2019-05-17 21:13:26 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2019-05-17 21:13:26 +0200 |
commit | b48f44bf77a39fefc238a16cf1225c6464c82406 (patch) | |
tree | f549ea742dbc826500b30235525ef9fb96769ad4 /gcc/cp/parser.c | |
parent | 5bf04509f437ff175c001a1c84a13b3a845174eb (diff) | |
download | gcc-b48f44bf77a39fefc238a16cf1225c6464c82406.tar.gz |
[PR89433] Repeated use of the C/C++ OpenACC 'routine' directive
gcc/
PR middle-end/89433
* omp-general.c (oacc_verify_routine_clauses): Change formal
parameters. Add checking if already marked with an OpenACC
'routine' directive. Adjust all users.
gcc/c/
PR c/89433
* c-parser.c (c_finish_oacc_routine): Rework checking if already
marked with an OpenACC 'routine' directive.
gcc/cp/
PR c++/89433
* parser.c (cp_finalize_oacc_routine): Rework checking if already
marked with an OpenACC 'routine' directive.
gcc/testsuite/
PR testsuite/89433
* c-c++-common/goacc/routine-5.c: Update.
* c-c++-common/goacc/routine-level-of-parallelism-1.c: Likewise.
* c-c++-common/goacc/routine-level-of-parallelism-2.c: New file.
From-SVN: r271345
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index aa6507e42f4..6705d64389c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -40272,36 +40272,42 @@ cp_finalize_oacc_routine (cp_parser *parser, tree fndecl, bool is_defn) return; } - oacc_verify_routine_clauses (&parser->oacc_routine->clauses, - parser->oacc_routine->loc); - - if (oacc_get_fn_attrib (fndecl)) + int compatible + = oacc_verify_routine_clauses (fndecl, &parser->oacc_routine->clauses, + parser->oacc_routine->loc, + "#pragma acc routine"); + if (compatible < 0) { - error_at (parser->oacc_routine->loc, - "%<#pragma acc routine%> already applied to %qD", fndecl); parser->oacc_routine = NULL; return; } - - if (TREE_USED (fndecl) || (!is_defn && DECL_SAVED_TREE (fndecl))) + if (compatible > 0) { - error_at (parser->oacc_routine->loc, - TREE_USED (fndecl) - ? G_("%<#pragma acc routine%> must be applied before use") - : G_("%<#pragma acc routine%> must be applied before " - "definition")); - parser->oacc_routine = NULL; - return; } + else + { + if (TREE_USED (fndecl) || (!is_defn && DECL_SAVED_TREE (fndecl))) + { + error_at (parser->oacc_routine->loc, + TREE_USED (fndecl) + ? G_("%<#pragma acc routine%> must be applied before" + " use") + : G_("%<#pragma acc routine%> must be applied before" + " definition")); + parser->oacc_routine = NULL; + return; + } - /* Process the routine's dimension clauses. */ - tree dims = oacc_build_routine_dims (parser->oacc_routine->clauses); - oacc_replace_fn_attrib (fndecl, dims); + /* Set the routine's level of parallelism. */ + tree dims = oacc_build_routine_dims (parser->oacc_routine->clauses); + oacc_replace_fn_attrib (fndecl, dims); - /* Add an "omp declare target" attribute. */ - DECL_ATTRIBUTES (fndecl) - = tree_cons (get_identifier ("omp declare target"), - parser->oacc_routine->clauses, DECL_ATTRIBUTES (fndecl)); + /* Add an "omp declare target" attribute. */ + DECL_ATTRIBUTES (fndecl) + = tree_cons (get_identifier ("omp declare target"), + parser->oacc_routine->clauses, + DECL_ATTRIBUTES (fndecl)); + } /* Don't unset parser->oacc_routine here: we may still need it to diagnose wrong usage. But, remember that we've used this "#pragma acc |