diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-07-23 09:37:36 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-07-23 09:37:36 +0200 |
commit | 2c5d803d03209478b4f060785c6f6ba2f0de88ad (patch) | |
tree | 6b07db47a86a003c6ee098da3e6bc7029969dda8 /gcc/cp/parser.h | |
parent | 19e05058799ffd611f4946d1871e747bae7a0046 (diff) | |
download | gcc-2c5d803d03209478b4f060785c6f6ba2f0de88ad.zip gcc-2c5d803d03209478b4f060785c6f6ba2f0de88ad.tar.gz gcc-2c5d803d03209478b4f060785c6f6ba2f0de88ad.tar.bz2 |
openmp: Diagnose invalid mixing of the attribute and pragma syntax directives
The OpenMP 5.1 spec says that the attribute and pragma syntax directives
should not be mixed on the same statement. The following patch adds diagnostic
for that,
[[omp::directive (...)]]
#pragma omp ...
is always an error and for the other order
#pragma omp ...
[[omp::directive (...)]]
it depends on whether the pragma directive is an OpenMP construct
(then it is an error because it needs a structured block or loop
or statement as body) or e.g. a standalone directive (then it is fine).
Only block scope is handled for now though, namespace scope and class scope
still needs implementing even the basic support.
2021-07-23 Jakub Jelinek <jakub@redhat.com>
gcc/c-family/
* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP__START_ and
PRAGMA_OMP__LAST_ enumerators.
gcc/cp/
* parser.h (struct cp_parser): Add omp_attrs_forbidden_p member.
* parser.c (cp_parser_handle_statement_omp_attributes): Diagnose
mixing of attribute and pragma syntax directives when seeing
omp::directive if parser->omp_attrs_forbidden_p or if attribute syntax
directives are followed by OpenMP pragma.
(cp_parser_statement): Clear parser->omp_attrs_forbidden_p after
the cp_parser_handle_statement_omp_attributes call.
(cp_parser_omp_structured_block): Add disallow_omp_attrs argument,
if true, set parser->omp_attrs_forbidden_p.
(cp_parser_omp_scan_loop_body, cp_parser_omp_sections_scope): Pass
false as disallow_omp_attrs to cp_parser_omp_structured_block.
(cp_parser_omp_parallel, cp_parser_omp_task): Set
parser->omp_attrs_forbidden_p.
gcc/testsuite/
* g++.dg/gomp/attrs-4.C: New test.
* g++.dg/gomp/attrs-5.C: New test.
Diffstat (limited to 'gcc/cp/parser.h')
-rw-r--r-- | gcc/cp/parser.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h index 5ef7047..6fdd214 100644 --- a/gcc/cp/parser.h +++ b/gcc/cp/parser.h @@ -398,6 +398,9 @@ struct GTY(()) cp_parser { identifiers) rather than an explicit template parameter list. */ bool fully_implicit_function_template_p; + /* TRUE if omp::directive or omp::sequence attributes may not appear. */ + bool omp_attrs_forbidden_p; + /* Tracks the function's template parameter list when declaring a function using generic type parameters. This is either a new chain in the case of a fully implicit function template or an extension of the function's existing |