diff mbox

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

Message ID 20111205202144.GN27242@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 5, 2011, 8:21 p.m. UTC
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.


	Jakub

Comments

Joseph Myers Dec. 5, 2011, 8:43 p.m. UTC | #1
On Mon, 5 Dec 2011, Jakub Jelinek wrote:

> 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.

OK.
Jakub Jelinek Feb. 9, 2012, 9:08 a.m. UTC | #2
On Thu, Feb 09, 2012 at 12:11:45AM +0100, Ulrich Weigand wrote:
> The finish_decl change appears to have introduced a regression
> in attribute ((aligned)) handling.  With the following code:
> 
> extern const int foo[];
> const int __attribute__((aligned(16))) foo[] = { 0 };
> 
> the attribute now seems to be ignored; reverting the change
> above causes the attribute to be honored again.

Seems the bug is elsewhere though, testing a fix, see
PR52181 I've filed for this.

	Jakub
diff mbox

Patch

--- 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';
+  }
+}