This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use relayout_decl instead of layout_decl when completing vars with incomplete types (PR c/51339)


Hi!

The following testcase ICEs, because in finish_decl the C FE doesn't
relayout_decl after changing the type from char [] to char [2], so it
is not updated from BLKmode to HImode.  WHen OpenMP creates the private
copy of the var, the type is complete from the beginning and therefore
it is HImode, and durng expansion when we try to expand HImode = BLKmode
assignment we ICE.  The C++ in these cases calls relayout_decl.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

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

	PR c/51339
	* c-decl.c (c_finish_incomplete_decl, finish_decl): Call
	relayout_decl instead of layout_decl.

	* gcc.dg/gomp/pr51339.c: New test.

--- gcc/c-decl.c.jj	2011-11-28 17:58:04.000000000 +0100
+++ gcc/c-decl.c	2011-12-05 16:39:46.713393079 +0100
@@ -719,7 +719,7 @@ c_finish_incomplete_decl (tree decl)
 
 	  complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
 
-	  layout_decl (decl, 0);
+	  relayout_decl (decl);
 	}
     }
 }
@@ -4311,7 +4311,7 @@ finish_decl (tree decl, location_t init_
       if (DECL_INITIAL (decl))
 	TREE_TYPE (DECL_INITIAL (decl)) = type;
 
-      layout_decl (decl, 0);
+      relayout_decl (decl);
     }
 
   if (TREE_CODE (decl) == VAR_DECL)
--- gcc/testsuite/gcc.dg/gomp/pr51339.c.jj	2011-12-05 17:23:12.190987532 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr51339.c	2011-12-05 17:22:50.000000000 +0100
@@ -0,0 +1,15 @@
+/* PR c/51339 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+char g[] = "g";
+
+void
+foo (void)
+{
+#pragma omp parallel sections firstprivate (g) lastprivate (g)
+  {
+  #pragma omp section
+    g[0] = 'h';
+  }
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]