]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Fix ICE on depend(source) clause during cdtor cloning [PR100957]
authorJakub Jelinek <jakub@redhat.com>
Tue, 8 Jun 2021 09:16:41 +0000 (11:16 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 8 Jun 2021 09:18:39 +0000 (11:18 +0200)
The depend(source) clause has NULL OMP_CLAUSE_DECL, it has just the
depend kind specified and no arguments.  So copy_tree_body_r shouldn't
check TREE_CODE on it without checking it is non-NULL.

2021-06-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/100957
* tree-inline.c (copy_tree_body_r): For OMP_CLAUSE_DEPEND don't
check TREE_CODE if OMP_CLAUSE_DECL is NULL.

* g++.dg/gomp/doacross-2.C: New test.

gcc/testsuite/g++.dg/gomp/doacross-2.C [new file with mode: 0644]
gcc/tree-inline.c

diff --git a/gcc/testsuite/g++.dg/gomp/doacross-2.C b/gcc/testsuite/g++.dg/gomp/doacross-2.C
new file mode 100644 (file)
index 0000000..1fd6357
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/100957
+// { dg-do compile }
+
+struct S {
+  S ()
+  {
+  #pragma omp for ordered(2)
+    for (int i = 0; i < 32; ++i)
+      for (int j = 0; j < 32; ++j)
+       {
+       #pragma omp ordered depend(source)
+         ;
+       #pragma omp ordered depend(sink: i - 1, j - 1)
+       }
+  }
+};
index 4250fd86487f34cebc973d9d0562d45da35db4af..9eb08d23320d49fe22a92bb16ae221c1bede8554 100644 (file)
@@ -1458,7 +1458,8 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data)
                   || OMP_CLAUSE_CODE (*tp) == OMP_CLAUSE_DEPEND))
        {
          tree t = OMP_CLAUSE_DECL (*tp);
-         if (TREE_CODE (t) == TREE_LIST
+         if (t
+             && TREE_CODE (t) == TREE_LIST
              && TREE_PURPOSE (t)
              && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
            {