This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp5] Reject range-based for loops with ordered(n) clause
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Oct 2018 10:41:34 +0200
- Subject: [gomp5] Reject range-based for loops with ordered(n) clause
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The spec says:
"The loops associated with an ordered clause with a parameter may not include range-for
loops."
This patch implements this restriction. Committed to gomp-5_0-branch.
2018-10-19 Jakub Jelinek <jakub@redhat.com>
* parser.c (cp_parser_omp_for_loop): Disallow ordered clause with
argument for range-for loops.
* g++.dg/gomp/doacross-1.C: New test.
--- gcc/cp/parser.c.jj 2018-10-18 10:17:14.098009735 +0200
+++ gcc/cp/parser.c 2018-10-19 10:36:05.631549494 +0200
@@ -36139,6 +36139,11 @@ cp_parser_omp_for_loop (cp_parser *parse
pre_body = this_pre_body;
}
+ if (ordered_cl)
+ error_at (OMP_CLAUSE_LOCATION (ordered_cl),
+ "%<ordered%> clause with parameter on "
+ "range-based %<for%> loop");
+
goto parse_close_paren;
}
}
--- gcc/testsuite/g++.dg/gomp/doacross-1.C.jj 2018-10-19 10:32:30.132148779 +0200
+++ gcc/testsuite/g++.dg/gomp/doacross-1.C 2018-10-19 10:37:44.930890996 +0200
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "-fopenmp" }
+
+int a[42];
+
+void
+foo ()
+{
+ #pragma omp for ordered (1) // { dg-error "'ordered' clause with parameter on range-based 'for' loop" }
+ for (auto x : a)
+ ;
+}
+
+void
+bar ()
+{
+ #pragma omp for ordered (2) // { dg-error "'ordered' clause with parameter on range-based 'for' loop" }
+ for (int i = 0; i < 1; i++)
+ for (auto x : a)
+ ;
+}
Jakub