aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-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/c/c-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/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index a66f43f..869a811 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -18976,6 +18976,31 @@ c_parser_omp_flush (c_parser *parser)
c_finish_omp_flush (loc, mo);
}
+/* Parse an OpenMP structured block sequence. KIND is the corresponding
+ separating directive. */
+
+static tree
+c_parser_omp_structured_block_sequence (c_parser *parser,
+ enum pragma_kind kind)
+{
+ tree stmt = push_stmt_list ();
+ c_parser_statement (parser, NULL);
+ do
+ {
+ if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
+ break;
+ if (c_parser_next_token_is (parser, CPP_EOF))
+ break;
+
+ if (kind != PRAGMA_NONE
+ && c_parser_peek_token (parser)->pragma_kind == kind)
+ break;
+ c_parser_statement (parser, NULL);
+ }
+ while (1);
+ return pop_stmt_list (stmt);
+}
+
/* OpenMP 5.0:
scan-loop-body:
@@ -18997,7 +19022,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
return;
}
- substmt = c_parser_omp_structured_block (parser, NULL);
+ substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
substmt = build2 (OMP_SCAN, void_type_node, substmt, NULL_TREE);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);
@@ -19032,7 +19057,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
error ("expected %<#pragma omp scan%>");
clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
- substmt = c_parser_omp_structured_block (parser, NULL);
+ substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_NONE);
substmt = build2 (OMP_SCAN, void_type_node, substmt, clauses);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);
@@ -19860,6 +19885,8 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context,
section-directive[opt] structured-block
section-sequence section-directive structured-block
+ OpenMP 5.1 allows structured-block-sequence instead of structured-block.
+
SECTIONS_LOC is the location of the #pragma omp sections. */
static tree
@@ -19881,7 +19908,8 @@ c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser)
if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION)
{
- substmt = c_parser_omp_structured_block (parser, NULL);
+ substmt = c_parser_omp_structured_block_sequence (parser,
+ PRAGMA_OMP_SECTION);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);
@@ -19907,7 +19935,8 @@ c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser)
error_suppress = true;
}
- substmt = c_parser_omp_structured_block (parser, NULL);
+ substmt = c_parser_omp_structured_block_sequence (parser,
+ PRAGMA_OMP_SECTION);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);