[PATCH] Don't segv in omp-low.c (PR middle-end/59669)

Marek Polacek polacek@redhat.com
Wed Jan 8 15:09:00 GMT 2014


We can also get NULL for the default definition, so we need to handle that
before calling has_zero_uses on it.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-01-08  Marek Polacek  <polacek@redhat.com>

	PR middle-end/59669
	* omp-low.c (simd_clone_adjust): Don't crash if def is NULL.
testsuite/
	* gcc.dg/gomp/pr59669.c: New test.

--- gcc/omp-low.c.mp	2014-01-08 13:48:40.353624984 +0100
+++ gcc/omp-low.c	2014-01-08 13:48:47.780656551 +0100
@@ -11587,7 +11587,7 @@ simd_clone_adjust (struct cgraph_node *n
 	tree def = ssa_default_def (cfun, orig_arg);
 	gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (orig_arg))
 		    || POINTER_TYPE_P (TREE_TYPE (orig_arg)));
-	if (!has_zero_uses (def))
+	if (def && !has_zero_uses (def))
 	  {
 	    iter1 = make_ssa_name (orig_arg, NULL);
 	    iter2 = make_ssa_name (orig_arg, NULL);
--- gcc/testsuite/gcc.dg/gomp/pr59669.c.mp	2014-01-08 13:50:23.710492087 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr59669.c	2014-01-08 13:50:54.339622411 +0100
@@ -0,0 +1,9 @@
+/* PR middle-end/59669 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+#pragma omp declare simd linear(a)
+void
+foo (int a)
+{
+}

	Marek



More information about the Gcc-patches mailing list