@@ -10391,18 +10391,6 @@ c_parser_omp_atomic (location_t loc, c_p
if (c_parser_next_token_is (parser, CPP_NAME))
{
const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
- if (!strcmp (p, "seq_cst"))
- {
- seq_cst = true;
- c_parser_consume_token (parser);
- if (c_parser_next_token_is (parser, CPP_COMMA)
- && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
- c_parser_consume_token (parser);
- }
- }
- if (c_parser_next_token_is (parser, CPP_NAME))
- {
- const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
if (!strcmp (p, "read"))
code = OMP_ATOMIC_READ;
@@ -10417,21 +10405,13 @@ c_parser_omp_atomic (location_t loc, c_p
if (p)
c_parser_consume_token (parser);
}
- if (!seq_cst)
+ if (c_parser_next_token_is (parser, CPP_NAME))
{
- if (c_parser_next_token_is (parser, CPP_COMMA)
- && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
- c_parser_consume_token (parser);
-
- if (c_parser_next_token_is (parser, CPP_NAME))
+ const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+ if (!strcmp (p, "seq_cst"))
{
- const char *p
- = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
- if (!strcmp (p, "seq_cst"))
- {
- seq_cst = true;
- c_parser_consume_token (parser);
- }
+ seq_cst = true;
+ c_parser_consume_token (parser);
}
}
c_parser_skip_to_pragma_eol (parser);
@@ -11231,21 +11211,7 @@ c_parser_omp_sections_scope (location_t
if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION)
{
- substmt = push_stmt_list ();
-
- while (1)
- {
- c_parser_statement (parser);
-
- if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_OMP_SECTION)
- break;
- if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
- break;
- if (c_parser_next_token_is (parser, CPP_EOF))
- break;
- }
-
- substmt = pop_stmt_list (substmt);
+ substmt = c_parser_omp_structured_block (parser);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
SET_EXPR_LOCATION (substmt, loc);
add_stmt (substmt);
@@ -10748,6 +10748,8 @@ c_finish_omp_clauses (tree clauses)
tree c, t, *pc = &clauses;
const char *name;
bool branch_seen = false;
+ bool copyprivate_seen = false;
+ tree *nowait_clause = NULL;
bitmap_obstack_initialize (NULL);
bitmap_initialize (&generic_head, &bitmap_default_obstack);
@@ -10828,6 +10830,15 @@ c_finish_omp_clauses (tree clauses)
case OMP_CLAUSE_COPYPRIVATE:
name = "copyprivate";
+ copyprivate_seen = true;
+ if (nowait_clause)
+ {
+ error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
+ "%<nowait%> clause must not be used together "
+ "with %<copyprivate%>");
+ *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
+ nowait_clause = NULL;
+ }
goto check_dup_generic;
case OMP_CLAUSE_COPYIN:
@@ -10994,10 +11005,22 @@ c_finish_omp_clauses (tree clauses)
}
break;
+ case OMP_CLAUSE_NOWAIT:
+ if (copyprivate_seen)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<nowait%> clause must not be used together "
+ "with %<copyprivate%>");
+ remove = true;
+ break;
+ }
+ nowait_clause = pc;
+ pc = &OMP_CLAUSE_CHAIN (c);
+ continue;
+
case OMP_CLAUSE_IF:
case OMP_CLAUSE_NUM_THREADS:
case OMP_CLAUSE_SCHEDULE:
- case OMP_CLAUSE_NOWAIT:
case OMP_CLAUSE_ORDERED:
case OMP_CLAUSE_DEFAULT:
case OMP_CLAUSE_UNTIED:
@@ -27939,20 +27939,6 @@ cp_parser_omp_atomic (cp_parser *parser,
tree id = cp_lexer_peek_token (parser->lexer)->u.value;
const char *p = IDENTIFIER_POINTER (id);
- if (!strcmp (p, "seq_cst"))
- {
- seq_cst = true;
- cp_lexer_consume_token (parser->lexer);
- if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
- && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME)
- cp_lexer_consume_token (parser->lexer);
- }
- }
- if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
- {
- tree id = cp_lexer_peek_token (parser->lexer)->u.value;
- const char *p = IDENTIFIER_POINTER (id);
-
if (!strcmp (p, "read"))
code = OMP_ATOMIC_READ;
else if (!strcmp (p, "write"))
@@ -27966,22 +27952,16 @@ cp_parser_omp_atomic (cp_parser *parser,
if (p)
cp_lexer_consume_token (parser->lexer);
}
- if (!seq_cst)
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
- if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
- && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME)
- cp_lexer_consume_token (parser->lexer);
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
- if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ if (!strcmp (p, "seq_cst"))
{
- tree id = cp_lexer_peek_token (parser->lexer)->u.value;
- const char *p = IDENTIFIER_POINTER (id);
-
- if (!strcmp (p, "seq_cst"))
- {
- seq_cst = true;
- cp_lexer_consume_token (parser->lexer);
- }
+ seq_cst = true;
+ cp_lexer_consume_token (parser->lexer);
}
}
cp_parser_require_pragma_eol (parser, pragma_tok);
@@ -29079,26 +29059,7 @@ cp_parser_omp_sections_scope (cp_parser
if (cp_lexer_peek_token (parser->lexer)->pragma_kind != PRAGMA_OMP_SECTION)
{
- unsigned save;
-
- substmt = begin_omp_structured_block ();
- save = cp_parser_begin_omp_structured_block (parser);
-
- while (1)
- {
- cp_parser_statement (parser, NULL_TREE, false, NULL);
-
- tok = cp_lexer_peek_token (parser->lexer);
- if (tok->pragma_kind == PRAGMA_OMP_SECTION)
- break;
- if (tok->type == CPP_CLOSE_BRACE)
- break;
- if (tok->type == CPP_EOF)
- break;
- }
-
- cp_parser_end_omp_structured_block (parser, save);
- substmt = finish_omp_structured_block (substmt);
+ substmt = cp_parser_omp_structured_block (parser);
substmt = build1 (OMP_SECTION, void_type_node, substmt);
add_stmt (substmt);
}
@@ -4555,6 +4555,7 @@ finish_omp_clauses (tree clauses)
tree c, t, *pc = &clauses;
const char *name;
bool branch_seen = false;
+ bool copyprivate_seen = false;
bitmap_obstack_initialize (NULL);
bitmap_initialize (&generic_head, &bitmap_default_obstack);
@@ -4579,6 +4580,7 @@ finish_omp_clauses (tree clauses)
goto check_dup_generic;
case OMP_CLAUSE_COPYPRIVATE:
name = "copyprivate";
+ copyprivate_seen = true;
goto check_dup_generic;
case OMP_CLAUSE_COPYIN:
name = "copyin";
@@ -5099,6 +5101,16 @@ finish_omp_clauses (tree clauses)
name = "copyin";
need_copy_assignment = true;
break;
+ case OMP_CLAUSE_NOWAIT:
+ if (copyprivate_seen)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<nowait%> clause must not be used together "
+ "with %<copyprivate%>");
+ *pc = OMP_CLAUSE_CHAIN (c);
+ continue;
+ }
+ /* FALLTHRU */
default:
pc = &OMP_CLAUSE_CHAIN (c);
continue;
@@ -6660,24 +6660,17 @@ expand_omp_single (struct omp_region *re
{
basic_block entry_bb, exit_bb;
gimple_stmt_iterator si;
- bool need_barrier = false;
entry_bb = region->entry;
exit_bb = region->exit;
si = gsi_last_bb (entry_bb);
- /* The terminal barrier at the end of a GOMP_single_copy sequence cannot
- be removed. We need to ensure that the thread that entered the single
- does not exit before the data is copied out by the other threads. */
- if (find_omp_clause (gimple_omp_single_clauses (gsi_stmt (si)),
- OMP_CLAUSE_COPYPRIVATE))
- need_barrier = true;
gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_SINGLE);
gsi_remove (&si, true);
single_succ_edge (entry_bb)->flags = EDGE_FALLTHRU;
si = gsi_last_bb (exit_bb);
- if (!gimple_omp_return_nowait_p (gsi_stmt (si)) || need_barrier)
+ if (!gimple_omp_return_nowait_p (gsi_stmt (si)))
{
tree t = gimple_omp_return_lhs (gsi_stmt (si));
gsi_insert_after (&si, build_omp_barrier (t), GSI_SAME_STMT);
@@ -22,8 +22,10 @@ void foo()
bar ();
#pragma omp parallel sections
{
- bar ();
- bar ();
+ {
+ bar ();
+ bar ();
+ }
#pragma omp section
bar ();
}
@@ -35,8 +35,10 @@ void foo()
#pragma omp sections
{
- goto ok1;
- ok1:;
+ {
+ goto ok1;
+ ok1:;
+ }
#pragma omp section
for (i = 0; i < 10; ++i)
@@ -35,9 +35,10 @@ void foo()
#pragma omp sections
{
- goto ok1;
- ok1:;
-
+ {
+ goto ok1;
+ ok1:;
+ }
#pragma omp section
for (i = 0; i < 10; ++i)
if (test(i))
@@ -28,17 +28,58 @@ f1 (void)
#pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
+ }
+ #pragma omp sections
+ {
#pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
+ }
+ #pragma omp sections
+ {
#pragma omp single /* { dg-error "may not be closely nested" } */
;
+ }
+ #pragma omp sections
+ {
#pragma omp master /* { dg-error "may not be closely nested" } */
;
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ ;
+ }
+ #pragma omp sections
+ {
#pragma omp section
+ #pragma omp for /* { dg-error "may not be closely nested" } */
+ for (j = 0; j < 3; j++)
+ ;
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
+ {
+ ;
+ #pragma omp section
+ ;
+ }
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ #pragma omp single /* { dg-error "may not be closely nested" } */
+ ;
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ #pragma omp master /* { dg-error "may not be closely nested" } */
;
}
#pragma omp single
@@ -0,0 +1,73 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void bar (int);
+
+void
+foo ()
+{
+ #pragma omp sections
+ {
+ bar (1);
+ #pragma omp section
+ {
+ bar (2);
+ }
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ bar (3);
+ #pragma omp section
+ {
+ bar (4);
+ bar (5);
+ }
+ }
+ #pragma omp sections
+ {
+ {
+ bar (6);
+ bar (7);
+ }
+ #pragma omp section
+ bar (8);
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ {
+ bar (9);
+ }
+ #pragma omp section
+ bar (10);
+ #pragma omp section
+ bar (11);
+ }
+ #pragma omp sections
+ {
+ } /* { dg-error "expression before" } */
+ #pragma omp sections
+ {
+ bar (12);
+ bar (13); /* { dg-error "pragma omp section" } */
+ #pragma omp section
+ bar (14);
+ }
+ #pragma omp sections
+ {
+ #pragma omp section
+ } /* { dg-error "expression before" } */
+ #pragma omp sections
+ {
+ bar (15);
+ #pragma omp section
+ bar (16);
+ bar (17); /* { dg-error "pragma omp section" } */
+ }
+ #pragma omp sections
+ {
+ bar (18);
+ #pragma omp section
+ } /* { dg-error "expression before" } */
+}
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (int i)
+{
+ #pragma omp single copyprivate (i)
+ ;
+ #pragma omp single nowait
+ ;
+ #pragma omp single copyprivate (i) nowait /* { dg-error "clause must not be used together with" } */
+ ;
+ #pragma omp single nowait copyprivate (i) /* { dg-error "clause must not be used together with" } */
+ ;
+}
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int x = 6;
+
+void
+foo ()
+{
+ int v;
+ #pragma omp atomic seq_cst load /* { dg-error "expected end of line" } */
+ v = x; /* { dg-error "invalid form" } */
+ #pragma omp atomic seq_cst, load /* { dg-error "expected end of line" } */
+ v = x; /* { dg-error "invalid form" } */
+ #pragma omp atomic seq_cst store /* { dg-error "expected end of line" } */
+ x = v; /* { dg-error "invalid form" } */
+ #pragma omp atomic seq_cst ,store /* { dg-error "expected end of line" } */
+ x = v; /* { dg-error "invalid form" } */
+ #pragma omp atomic seq_cst update /* { dg-error "expected end of line" } */
+ x += v;
+ #pragma omp atomic seq_cst , update /* { dg-error "expected end of line" } */
+ x += v;
+ #pragma omp atomic seq_cst capture /* { dg-error "expected end of line" } */
+ v = x += 2; /* { dg-error "invalid form" } */
+ #pragma omp atomic seq_cst, capture /* { dg-error "expected end of line" } */
+ v = x += 2; /* { dg-error "invalid form" } */
+ #pragma omp atomic load , seq_cst /* { dg-error "expected end of line" } */
+ v = x; /* { dg-error "invalid form" } */
+ #pragma omp atomic store ,seq_cst /* { dg-error "expected end of line" } */
+ x = v; /* { dg-error "invalid form" } */
+ #pragma omp atomic update, seq_cst /* { dg-error "expected end of line" } */
+ x += v;
+ #pragma omp atomic capture, seq_cst /* { dg-error "expected end of line" } */
+ v = x += 2;
+}
@@ -13,13 +13,13 @@ main ()
v = x;
if (v != 3)
abort ();
- #pragma omp atomic seq_cst update
+ #pragma omp atomic update seq_cst
x = 3 * 2 * 1 + x;
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 9)
abort ();
- #pragma omp atomic seq_cst, capture
+ #pragma omp atomic capture seq_cst
v = x = x | 16;
if (v != 25)
abort ();
@@ -27,15 +27,15 @@ main ()
v = x = x + 14 * 2 / 4;
if (v != 32)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
v = x = 5 | x;
if (v != 37)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
v = x = 40 + 12 - 2 - 7 - x;
if (v != 6)
abort ();
- #pragma omp atomic seq_cst read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -43,7 +43,7 @@ main ()
{ v = x; x = 3 + x; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = -1 * -1 * -1 * -1 - x; }
if (v != 9)
abort ();
@@ -51,11 +51,11 @@ main ()
v = x;
if (v != -8)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
{ x = 2 * 2 - x; v = x; }
if (v != 12)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ x = 7 & x; v = x; }
if (v != 4)
abort ();
@@ -63,7 +63,7 @@ main ()
{ v = x; x = 6; }
if (v != 4)
abort ();
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -71,11 +71,11 @@ main ()
{ v = x; x = 7 * 8 + 23; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst, read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 79)
abort ();
- #pragma omp atomic capture , seq_cst
+ #pragma omp atomic capture seq_cst
{ v = x; x = 23 + 6 * 4; }
if (v != 79)
abort ();
@@ -83,7 +83,7 @@ main ()
v = x;
if (v != 47)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = l ? 17 : 12; }
if (v != 47)
abort ();
@@ -14,13 +14,13 @@ foo ()
v = x;
if (v != 3)
abort ();
- #pragma omp atomic seq_cst update
+ #pragma omp atomic update seq_cst
x = 3 * 2 * 1 + x;
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 9)
abort ();
- #pragma omp atomic seq_cst, capture
+ #pragma omp atomic capture seq_cst
v = x = x | 16;
if (v != 25)
abort ();
@@ -28,15 +28,15 @@ foo ()
v = x = x + 14 * 2 / 4;
if (v != 32)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
v = x = 5 | x;
if (v != 37)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
v = x = 40 + 12 - 2 - 7 - x;
if (v != 6)
abort ();
- #pragma omp atomic seq_cst read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -44,7 +44,7 @@ foo ()
{ v = x; x = 3 + x; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = -1 * -1 * -1 * -1 - x; }
if (v != 9)
abort ();
@@ -52,11 +52,11 @@ foo ()
v = x;
if (v != -8)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
{ x = 2 * 2 - x; v = x; }
if (v != 12)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ x = 7 & x; v = x; }
if (v != 4)
abort ();
@@ -64,7 +64,7 @@ foo ()
{ v = x; x = 6; }
if (v != 4)
abort ();
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -72,11 +72,11 @@ foo ()
{ v = x; x = 7 * 8 + 23; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst, read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 79)
abort ();
- #pragma omp atomic capture , seq_cst
+ #pragma omp atomic capture seq_cst
{ v = x; x = 23 + 6 * 4; }
if (v != 79)
abort ();
@@ -84,7 +84,7 @@ foo ()
v = x;
if (v != 47)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = l ? 17 : 12; }
if (v != 47)
abort ();
@@ -13,13 +13,13 @@ main ()
v = x;
if (v != 3)
abort ();
- #pragma omp atomic seq_cst update
+ #pragma omp atomic update seq_cst
x = 3 * 2 * 1 + x;
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 9)
abort ();
- #pragma omp atomic seq_cst, capture
+ #pragma omp atomic capture seq_cst
v = x = x | 16;
if (v != 25)
abort ();
@@ -27,15 +27,15 @@ main ()
v = x = x + 14 * 2 / 4;
if (v != 32)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
v = x = 5 | x;
if (v != 37)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
v = x = 40 + 12 - 2 - 7 - x;
if (v != 6)
abort ();
- #pragma omp atomic seq_cst read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -43,7 +43,7 @@ main ()
{ v = x; x = 3 + x; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = -1 * -1 * -1 * -1 - x; }
if (v != 9)
abort ();
@@ -51,11 +51,11 @@ main ()
v = x;
if (v != -8)
abort ();
- #pragma omp atomic capture, seq_cst
+ #pragma omp atomic capture seq_cst
{ x = 2 * 2 - x; v = x; }
if (v != 12)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ x = 7 & x; v = x; }
if (v != 4)
abort ();
@@ -63,7 +63,7 @@ main ()
{ v = x; x = 6; }
if (v != 4)
abort ();
- #pragma omp atomic read, seq_cst
+ #pragma omp atomic read seq_cst
v = x;
if (v != 6)
abort ();
@@ -71,11 +71,11 @@ main ()
{ v = x; x = 7 * 8 + 23; }
if (v != 6)
abort ();
- #pragma omp atomic seq_cst, read
+ #pragma omp atomic read seq_cst
v = x;
if (v != 79)
abort ();
- #pragma omp atomic capture , seq_cst
+ #pragma omp atomic capture seq_cst
{ v = x; x = 23 + 6 * 4; }
if (v != 79)
abort ();
@@ -83,7 +83,7 @@ main ()
v = x;
if (v != 47)
abort ();
- #pragma omp atomic seq_cst capture
+ #pragma omp atomic capture seq_cst
{ v = x; x = l ? 17 : 12; }
if (v != 47)
abort ();