Hi!

The c_parser_omp_clause_dist_schedule function had a pasto in it, so instead
of checking for duplicate DIST_SCHEDULE clause it complained if there was a
schedule clause before it, which is valid on combined constructs as can be
seen on the first testcase.
Furthermore, I've discovered that OpenMP actually doesn't require that there
is no duplicate dist_schedule (although it should, filed an issue and it is
likely going to be in OpenMP 5.1), so I've downgraded that temporarily just
to a warning to be pedantically correct.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk,
queued for backporting.

2019-08-09  Jakub Jelinek  <ja...@redhat.com>

        PR c/91401
c/
        * c-parser.c (c_parser_omp_clause_dist_schedule): Fix up typos in the
        check_no_duplicate_clause call.  Comment it out, instead emit a
        warning for duplicate dist_schedule clauses.
cp/
        * parser.c (cp_parser_omp_clause_dist_schedule): Comment out the
        check_no_duplicate_clause call, instead emit a warning for duplicate
        dist_schedule clauses.
testsuite/
        * c-c++-common/gomp/pr91401-1.c: New test.
        * c-c++-common/gomp/pr91401-2.c: New test.

--- gcc/c/c-parser.c.jj 2019-08-08 13:09:14.645488373 +0200
+++ gcc/c/c-parser.c    2019-08-08 17:52:01.123649009 +0200
@@ -14811,7 +14804,10 @@ c_parser_omp_clause_dist_schedule (c_par
     c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
                               "expected %<,%> or %<)%>");
 
-  check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule");
+  /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
+                               "dist_schedule"); */
+  if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
+    warning_at (loc, 0, "too many %qs clauses", "dist_schedule");
   if (t == error_mark_node)
     return list;
 
--- gcc/cp/parser.c.jj  2019-08-08 13:09:14.649488313 +0200
+++ gcc/cp/parser.c     2019-08-08 17:33:26.701273982 +0200
@@ -35258,8 +35252,10 @@ cp_parser_omp_clause_dist_schedule (cp_p
   else if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_COMMA_CLOSE_PAREN))
     goto resync_fail;
 
-  check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, "dist_schedule",
-                            location);
+  /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
+                               "dist_schedule", location); */
+  if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
+    warning_at (location, 0, "too many %qs clauses", "dist_schedule");
   OMP_CLAUSE_CHAIN (c) = list;
   return c;
 
--- gcc/testsuite/c-c++-common/gomp/pr91401-1.c.jj      2019-08-08 
18:01:07.451499483 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr91401-1.c 2019-08-08 18:00:56.118668781 
+0200
@@ -0,0 +1,10 @@
+/* PR c/91401 */
+
+void
+foo (void)
+{
+  int i;
+  #pragma omp distribute parallel for schedule (static) dist_schedule (static)
+  for (i = 0; i < 64; i++)
+    ;
+}
--- gcc/testsuite/c-c++-common/gomp/pr91401-2.c.jj      2019-08-08 
18:20:30.632137143 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr91401-2.c 2019-08-08 18:20:41.855969933 
+0200
@@ -0,0 +1,15 @@
+#pragma omp declare target
+void f0 (void);
+
+void
+f1 (void)
+{
+  int i;
+  #pragma omp distribute dist_schedule(static) dist_schedule(static)   /* { 
dg-warning "too many 'dist_schedule' clauses" } */
+  for (i = 0; i < 8; ++i)
+    f0 ();
+  #pragma omp distribute dist_schedule(static,2) dist_schedule(static,4) /* { 
dg-warning "too many 'dist_schedule' clauses" } */
+  for (i = 0; i < 8; ++i)
+    f0 ();
+}
+#pragma omp end declare target

        Jakub

Reply via email to