This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp] Disallow 'nowait' in combined parallel+workshare directives
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 31 Oct 2005 13:57:40 -0500
- Subject: [gomp] Disallow 'nowait' in combined parallel+workshare directives
The standard does not allow 'nowait' in combined parallel+workshare
directives.
Jakub, I'm not quite sure whether Fortran already checks for this. If it
doesn't, could you add it? Thanks.
* c-omp.c (c_split_parallel_clauses): Ignore OMP_CLAUSE_NOWAIT.
* c-parser.c (c_parser_omp_parallel): Do not allow 'nowait' in
combined parallel+workshare directives.
omp-builtins.def: Add comments warning about ordering of some
builtins.
cp/
* parser.c (cp_parser_omp_parallel): Do not allow 'nowait' in
combined parallel+workshare directives.
testsuite/
* gcc.dg/gomp/sections-3.c: New test.
* gcc.dg/gomp/parallel-4.c: New test.
* g++.dg/gomp/parallel-5.C: New test.
* g++.dg/gomp/sections-3.C: New test.
Index: testsuite/gcc.dg/gomp/sections-3.c
===================================================================
--- testsuite/gcc.dg/gomp/sections-3.c (revision 0)
+++ testsuite/gcc.dg/gomp/sections-3.c (revision 0)
@@ -0,0 +1,15 @@
+
+// { dg-do compile }
+
+extern void bar (void);
+
+int main (void)
+{
+ #pragma omp parallel sections nowait /* { dg-error "'nowait'" } */
+ {
+ #pragma omp section
+ { bar(); }
+ #pragma omp section
+ { bar(); }
+ }
+}
Index: testsuite/gcc.dg/gomp/parallel-4.c
===================================================================
--- testsuite/gcc.dg/gomp/parallel-4.c (revision 0)
+++ testsuite/gcc.dg/gomp/parallel-4.c (revision 0)
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+extern void bar (void);
+
+int main (void)
+{
+ int i;
+#pragma omp parallel for nowait /* { dg-error "'nowait'" } */
+ for (i = 0; i < 10; i++)
+ bar ();
+}
Index: testsuite/g++.dg/gomp/parallel-5.C
===================================================================
--- testsuite/g++.dg/gomp/parallel-5.C (revision 0)
+++ testsuite/g++.dg/gomp/parallel-5.C (revision 0)
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+extern void bar (void);
+
+int main (void)
+{
+ int i;
+#pragma omp parallel for nowait /* { dg-error "'nowait'" } */
+ for (i = 0; i < 10; i++)
+ bar ();
+}
Index: testsuite/g++.dg/gomp/sections-3.C
===================================================================
--- testsuite/g++.dg/gomp/sections-3.C (revision 0)
+++ testsuite/g++.dg/gomp/sections-3.C (revision 0)
@@ -0,0 +1,15 @@
+
+// { dg-do compile }
+
+extern void bar (void);
+
+int main (void)
+{
+ #pragma omp parallel sections nowait /* { dg-error "'nowait'" } */
+ {
+ #pragma omp section
+ { bar(); }
+ #pragma omp section
+ { bar(); }
+ }
+}
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 106276)
+++ cp/parser.c (working copy)
@@ -18534,6 +18534,7 @@ cp_parser_omp_parallel (cp_parser *parse
p_kind = PRAGMA_OMP_PARALLEL_FOR;
p_name = "#pragma omp parallel for";
mask |= OMP_FOR_CLAUSE_MASK;
+ mask &= ~(1u << PRAGMA_OMP_CLAUSE_NOWAIT);
}
else if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
@@ -18545,6 +18546,7 @@ cp_parser_omp_parallel (cp_parser *parse
p_kind = PRAGMA_OMP_PARALLEL_SECTIONS;
p_name = "#pragma omp parallel sections";
mask |= OMP_SECTIONS_CLAUSE_MASK;
+ mask &= ~(1u << PRAGMA_OMP_CLAUSE_NOWAIT);
}
}
Index: c-omp.c
===================================================================
--- c-omp.c (revision 106276)
+++ c-omp.c (working copy)
@@ -352,6 +352,10 @@ c_split_parallel_clauses (tree clauses,
*ws_clauses = clauses;
break;
+ case OMP_CLAUSE_NOWAIT:
+ /* Ignore. It is invalid in combined parallel contstructs. */
+ break;
+
default:
gcc_unreachable ();
}
Index: omp-builtins.def
===================================================================
--- omp-builtins.def (revision 106276)
+++ omp-builtins.def (working copy)
@@ -46,6 +46,9 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_CRITICAL
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_CRITICAL_NAME_END,
"GOMP_critical_name_end",
BT_FN_VOID_PTRPTR, ATTR_NOTHROW_LIST)
+/* NOTE: Do not change the order of BUILT_IN_GOMP_LOOP_*_START. They
+ are used in index arithmetic with enum omp_clause_schedule_kind
+ in omp-low.c. */
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_START,
"GOMP_loop_static_start",
BT_FN_BOOL_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR,
@@ -98,6 +101,9 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_ORD
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_ORDERED_RUNTIME_NEXT,
"GOMP_loop_ordered_runtime_next",
BT_FN_BOOL_LONGPTR_LONGPTR, ATTR_NOTHROW_LIST)
+/* NOTE: Do not change the order of BUILT_IN_GOMP_PARALLEL_LOOP_*_START.
+ They are used in index arithmetic with enum omp_clause_schedule_kind
+ in omp-low.c. */
DEF_GOMP_BUILTIN (BUILT_IN_GOMP_PARALLEL_LOOP_STATIC_START,
"GOMP_parallel_loop_static_start",
BT_FN_VOID_OMPFN_PTR_UINT_LONG_LONG_LONG_LONG,
Index: c-parser.c
===================================================================
--- c-parser.c (revision 106276)
+++ c-parser.c (working copy)
@@ -7556,6 +7556,7 @@ c_parser_omp_parallel (c_parser *parser)
p_kind = PRAGMA_OMP_PARALLEL_FOR;
p_name = "#pragma omp parallel for";
mask |= OMP_FOR_CLAUSE_MASK;
+ mask &= ~(1u << PRAGMA_OMP_CLAUSE_NOWAIT);
}
else if (c_parser_next_token_is (parser, CPP_NAME))
{
@@ -7566,6 +7567,7 @@ c_parser_omp_parallel (c_parser *parser)
p_kind = PRAGMA_OMP_PARALLEL_SECTIONS;
p_name = "#pragma omp parallel sections";
mask |= OMP_SECTIONS_CLAUSE_MASK;
+ mask &= ~(1u << PRAGMA_OMP_CLAUSE_NOWAIT);
}
}
@@ -7581,23 +7583,19 @@ c_parser_omp_parallel (c_parser *parser)
case PRAGMA_OMP_PARALLEL_FOR:
block = c_begin_omp_parallel ();
-
c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
stmt = c_parser_omp_for_loop (parser);
if (stmt)
OMP_FOR_CLAUSES (stmt) = ws_clause;
-
stmt = c_finish_omp_parallel (par_clause, block);
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
block = c_begin_omp_parallel ();
-
c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
stmt = c_parser_omp_sections_scope (parser);
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
-
stmt = c_finish_omp_parallel (par_clause, block);
break;