[gomp] Fix ICE in build_outer_var_ref (part of PR middle-end/27416)

Jakub Jelinek jakub@redhat.com
Fri May 12 18:08:00 GMT 2006


Hi!

The following testcase is IMHO valid, the dummy argument is shared (because
the actual argument is shared), so build_outer_var_ref needs to handle it
gracefully.

Ok for trunk?

2006-05-12  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/27416
	* omp-low.c (build_outer_var_ref): If VAR is reference in orphaned
	construct, return *VAR.

	* libgomp.fortran/pr27416-1.f90: New test.

--- gcc/omp-low.c.jj	2006-05-10 14:07:01.000000000 +0200
+++ gcc/omp-low.c	2006-05-12 16:11:52.000000000 +0200
@@ -577,6 +577,10 @@ build_outer_var_ref (tree var, omp_conte
     }
   else if (ctx->outer)
     x = lookup_decl (var, ctx->outer);
+  else if (is_reference (var))
+    /* This can happen with orphaned constructs.  If var is reference, it is
+       possible it is shared and as such valid.  */
+    x = var;
   else
     gcc_unreachable ();
 
--- libgomp/testsuite/libgomp.fortran/pr27416-1.f90.jj	2006-05-12 16:26:14.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/pr27416-1.f90	2006-05-12 14:35:41.000000000 +0200
@@ -0,0 +1,19 @@
+! PR middle-end/27416
+! { dg-do run }
+
+  integer :: j
+  j = 6
+!$omp parallel num_threads (4)
+  call foo (j)
+!$omp end parallel
+  if (j.ne.6+16) call abort
+end
+
+subroutine foo (j)
+  integer :: i, j
+
+!$omp do firstprivate (j) lastprivate (j)
+  do i = 1, 16
+    if (i.eq.16) j = j + i
+  end do
+end subroutine foo

	Jakub



More information about the Gcc-patches mailing list