aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-09 10:14:36 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-09 10:14:36 +0200
commit875124eb0822d8905d73bd30d51421ba8afde282 (patch)
treea6e08723492dd20513002f469b2e3dd969ad2644 /gcc/cp/parser.c
parent0d788c358b94d0e1983e0c6bf6269fa105b6d007 (diff)
downloadgcc-875124eb0822d8905d73bd30d51421ba8afde282.zip
gcc-875124eb0822d8905d73bd30d51421ba8afde282.tar.gz
gcc-875124eb0822d8905d73bd30d51421ba8afde282.tar.bz2
openmp: Add support for OpenMP 5.1 structured-block-sequences
Related to this is the addition of structured-block-sequence in OpenMP 5.1, which doesn't change anything for Fortran, but for C/C++ allows multiple statements instead of just one possibly compound around the separating directives (section and scan). I've also made some updates to the OpenMP 5.1 support list in libgomp.texi. 2021-10-09 Jakub Jelinek <jakub@redhat.com> gcc/c/ * c-parser.c (c_parser_omp_structured_block_sequence): New function. (c_parser_omp_scan_loop_body): Use it. (c_parser_omp_sections_scope): Likewise. gcc/cp/ * parser.c (cp_parser_omp_structured_block): Remove disallow_omp_attrs argument. (cp_parser_omp_structured_block_sequence): New function. (cp_parser_omp_scan_loop_body): Use it. (cp_parser_omp_sections_scope): Likewise. gcc/testsuite/ * c-c++-common/gomp/sections1.c (foo): Don't expect errors on multiple statements in between section directive(s). Add testcases for invalid no statements in between section directive(s). * gcc.dg/gomp/sections-2.c (foo): Don't expect errors on multiple statements in between section directive(s). * g++.dg/gomp/sections-2.C (foo): Likewise. * g++.dg/gomp/attrs-6.C (foo): Add testcases for multiple statements in between section directive(s). (bar): Add testcases for multiple statements in between scan directive. * g++.dg/gomp/attrs-7.C (bar): Adjust expected error recovery. libgomp/ * libgomp.texi (OpenMP 5.1): Mention implemented support for structured block sequences in C/C++. Mention support for unconstrained/reproducible modifiers on order clause. Mention partial (C/C++ only) support of extentensions to atomics construct. Mention partial (C/C++ on clause only) support of align/allocator modifiers on allocate clause.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c7005eb..0818d66 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -40136,14 +40136,12 @@ cp_parser_end_omp_structured_block (cp_parser *parser, unsigned save)
}
static tree
-cp_parser_omp_structured_block (cp_parser *parser, bool *if_p,
- bool disallow_omp_attrs = true)
+cp_parser_omp_structured_block (cp_parser *parser, bool *if_p)
{
tree stmt = begin_omp_structured_block ();
unsigned int save = cp_parser_begin_omp_structured_block (parser);
- if (disallow_omp_attrs)
- parser->omp_attrs_forbidden_p = true;
+ parser->omp_attrs_forbidden_p = true;
cp_parser_statement (parser, NULL_TREE, false, if_p);
cp_parser_end_omp_structured_block (parser, save);
@@ -42001,6 +41999,43 @@ cp_parser_omp_section_scan (cp_parser *parser, const char *directive,
return true;
}
+/* Parse an OpenMP structured block sequence. KIND is the corresponding
+ separating directive. */
+
+static tree
+cp_parser_omp_structured_block_sequence (cp_parser *parser,
+ enum pragma_kind kind)
+{
+ tree stmt = begin_omp_structured_block ();
+ unsigned int save = cp_parser_begin_omp_structured_block (parser);
+
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
+ while (true)
+ {
+ cp_token *token = cp_lexer_peek_token (parser->lexer);
+
+ if (token->type == CPP_CLOSE_BRACE
+ || token->type == CPP_EOF
+ || token->type == CPP_PRAGMA_EOL
+ || (token->type == CPP_KEYWORD && token->keyword == RID_AT_END)
+ || (kind != PRAGMA_NONE
+ && cp_parser_pragma_kind (token) == kind))
+ break;
+
+ if (kind != PRAGMA_NONE
+ && cp_parser_omp_section_scan (parser,
+ kind == PRAGMA_OMP_SCAN
+ ? "scan" : "section", false))
+ break;
+
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
+ }
+
+ cp_parser_end_omp_structured_block (parser, save);
+ return finish_omp_structured_block (stmt);
+}
+
+
/* OpenMP 5.0:
scan-loop-body:
@@ -42015,11 +42050,10 @@ cp_parser_omp_scan_loop_body (cp_parser *parser)
if (!braces.require_open (parser))
return;
- substmt = cp_parser_omp_structured_block (parser, NULL, false);
+ substmt = cp_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
substmt = build2 (OMP_SCAN, void_type_node, substmt, NULL_TREE);
add_stmt (substmt);
- cp_parser_omp_section_scan (parser, "scan", false);
cp_token *tok = cp_lexer_peek_token (parser->lexer);
if (cp_parser_pragma_kind (tok) == PRAGMA_OMP_SCAN)
{
@@ -42055,7 +42089,7 @@ cp_parser_omp_scan_loop_body (cp_parser *parser)
error ("expected %<#pragma omp scan%>");
clauses = finish_omp_clauses (clauses, C_ORT_OMP);
- substmt = cp_parser_omp_structured_block (parser, NULL, false);
+ substmt = cp_parser_omp_structured_block_sequence (parser, PRAGMA_NONE);
substmt = build2_loc (tok->location, OMP_SCAN, void_type_node, substmt,
clauses);
add_stmt (substmt);
@@ -42924,7 +42958,8 @@ cp_parser_omp_sections_scope (cp_parser *parser)
!= PRAGMA_OMP_SECTION
&& !cp_parser_omp_section_scan (parser, "section", true))
{
- substmt = cp_parser_omp_structured_block (parser, NULL, false);
+ substmt = cp_parser_omp_structured_block_sequence (parser,
+ PRAGMA_OMP_SECTION);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
add_stmt (substmt);
}
@@ -42951,7 +42986,8 @@ cp_parser_omp_sections_scope (cp_parser *parser)
error_suppress = true;
}
- substmt = cp_parser_omp_structured_block (parser, NULL, false);
+ substmt = cp_parser_omp_structured_block_sequence (parser,
+ PRAGMA_OMP_SECTION);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
add_stmt (substmt);
}