aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-parser.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 21bc316..9398c7a 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -20112,6 +20112,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
tree substmt;
location_t loc;
tree clauses = NULL_TREE;
+ bool found_scan = false;
loc = c_parser_peek_token (parser)->location;
if (!open_brace_parsed
@@ -20122,7 +20123,15 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
return;
}
- substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
+ if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SCAN)
+ substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
+ else
+ {
+ warning_at (c_parser_peek_token (parser)->location, 0,
+ "%<#pragma omp scan%> with zero preceding executable "
+ "statements");
+ substmt = build_empty_stmt (loc);
+ }
substmt = build2 (OMP_SCAN, void_type_node, substmt, NULL_TREE);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);
@@ -20131,6 +20140,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_OMP_SCAN)
{
enum omp_clause_code clause = OMP_CLAUSE_ERROR;
+ found_scan = true;
c_parser_consume_pragma (parser);
@@ -20160,7 +20170,15 @@ 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_sequence (parser, PRAGMA_NONE);
+ if (!c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
+ substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_NONE);
+ else
+ {
+ if (found_scan)
+ warning_at (loc, 0, "%<#pragma omp scan%> with zero succeeding "
+ "executable statements");
+ substmt = build_empty_stmt (loc);
+ }
substmt = build2 (OMP_SCAN, void_type_node, substmt, clauses);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);