diff mbox series

[committed] openmp: Fix ICE on depend(source) clause during cdtor cloning [PR100957]

Message ID 20210608091944.GO7746@tucnak
State New
Headers show
Series [committed] openmp: Fix ICE on depend(source) clause during cdtor cloning [PR100957] | expand

Commit Message

Jakub Jelinek June 8, 2021, 9:19 a.m. UTC
Hi!

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.

Tested on x86_64-linux, committed to trunk.

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.


	Jakub
diff mbox series

Patch

--- gcc/tree-inline.c.jj	2021-06-07 09:25:30.541217037 +0200
+++ gcc/tree-inline.c	2021-06-08 10:40:07.013853127 +0200
@@ -1458,7 +1458,8 @@  copy_tree_body_r (tree *tp, int *walk_su
 		   || 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)
 	    {
--- gcc/testsuite/g++.dg/gomp/doacross-2.C.jj	2021-06-08 10:43:22.469121933 +0200
+++ gcc/testsuite/g++.dg/gomp/doacross-2.C	2021-06-08 10:42:39.648720282 +0200
@@ -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)
+	}
+  }
+};