openmp: Fix ICE when splitting invalid depend(source)/depend(sink:vec)
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Sep 2022 07:21:10 +0000 (09:21 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 6 Sep 2022 07:23:40 +0000 (09:23 +0200)
As we now create OMP_CLAUSE_DOACROSS rather than OMP_CLAUSE_DEPEND when
depend is used with source/sink modifiers, c_omp_split_clauses can see
OMP_CLAUSE_DOACROSS clause too before we diagnose it as erroneous.

The following patch treats it like OMP_CLAUSE_DEPEND during
the splitting but adds an assertion.

2022-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c/106836
* c-omp.cc (c_omp_split_clauses): Handle OMP_CLAUSE_DOACROSS.

* c-c++-common/gomp/pr106836.c: New test.

gcc/c-family/c-omp.cc
gcc/testsuite/c-c++-common/gomp/pr106836.c [new file with mode: 0644]

index 56bc4b1..1b086d8 100644 (file)
@@ -1877,6 +1877,12 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
        case OMP_CLAUSE_DEPEND:
          s = C_OMP_CLAUSE_SPLIT_TARGET;
          break;
+       case OMP_CLAUSE_DOACROSS:
+         /* This can happen with invalid depend(source) or
+            depend(sink:vec) on target combined with other constructs.  */
+         gcc_assert (OMP_CLAUSE_DOACROSS_DEPEND (clauses));
+         s = C_OMP_CLAUSE_SPLIT_TARGET;
+         break;
        case OMP_CLAUSE_NUM_TEAMS:
          s = C_OMP_CLAUSE_SPLIT_TEAMS;
          break;
diff --git a/gcc/testsuite/c-c++-common/gomp/pr106836.c b/gcc/testsuite/c-c++-common/gomp/pr106836.c
new file mode 100644 (file)
index 0000000..6df8250
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/106836 */
+
+void
+foo (void)
+{
+#pragma omp target parallel depend (source)    /* { dg-error "'depend\\\(source\\\)' is only allowed in 'omp ordered'" } */
+  ;
+#pragma omp taskwait
+}