]> 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:45:02 +0000 (11:45 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 8 Jun 2021 09:45:14 +0000 (11:45 +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.

(cherry picked from commit 8b4641033ab6901c18f68b98843f1038a9a52e03)

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

index 25717436651773ed61b37013831dabf74e08d927..8bedf3033e98256c0d1b5dc4ba6d98b1afe3984c 100644 (file)
@@ -1,3 +1,12 @@
+2021-06-08  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       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.
+
 2021-06-04  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
index 5221047c0c9f4f90b7b8de9698cd3be49c58bf77..a0f0bcd94df4d1e220e28429f8cc4aadcf832f6a 100644 (file)
@@ -1,3 +1,11 @@
+2021-06-08  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-06-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/100957
+       * g++.dg/gomp/doacross-2.C: New test.
+
 2021-06-08  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
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 78dc64886c480e231f8fb4fb1d3359c50bafa5bf..0f607808801f5426755a9678eb0e5f6aee8b4732 100644 (file)
@@ -1482,7 +1482,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)
            {