From: hjl Date: Mon, 18 Feb 2008 23:43:23 +0000 (+0000) Subject: gcc/ X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=beebc64a4e93e7006a311696b6373873598f080b gcc/ 2008-02-18 Joey Ye PR middle-end/34921 * tree-nested.c (insert_field_into_struct): Set type alignment to field alignment if the former is less than the latter. gcc/testsuite/ 2008-02-18 Joey Ye H.J. Lu PR middle-end/34921 * gcc.c-torture/execute/nest-align-1.c: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132396 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6030004eaf0..3ecc40c8132 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-02-18 Joey Ye + + PR middle-end/34921 + * tree-nested.c (insert_field_into_struct): Set type alignment + to field alignment if the former is less than the latter. + 2008-02-18 Jakub Jelinek * BASE-VER: Set to 4.4.0. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f8b32a7258..79db2f1bce9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-02-18 Joey Ye + H.J. Lu + + PR middle-end/34921 + * gcc.c-torture/execute/nest-align-1.c: New test case. + 2008-02-17 Richard Guenther PR middle-end/35227 diff --git a/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c b/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c new file mode 100644 index 00000000000..6099a5001c9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c @@ -0,0 +1,40 @@ +/* Test for alignment handling when a variable is accessed by nested + function. */ +/* Origin: Joey Ye */ + +#include + +typedef int aligned __attribute__((aligned(16))); +extern void abort (void); + +void +check (int *i) +{ + *i = 20; + if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0) + abort (); +} + +void +foo (void) +{ + aligned jj; + void bar () + { + jj = -20; + } + jj = 0; + bar (); + if (jj != -20) + abort (); + check (&jj); + if (jj != 20) + abort (); +} + +int +main() +{ + foo (); + return 0; +} diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index a20e320ad2e..2c1b9190d85 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -183,6 +183,10 @@ insert_field_into_struct (tree type, tree field) TREE_CHAIN (field) = *p; *p = field; + + /* Set correct alignment for frame struct type. */ + if (TYPE_ALIGN (type) < DECL_ALIGN (field)) + TYPE_ALIGN (type) = DECL_ALIGN (field); } /* Build or return the RECORD_TYPE that describes the frame state that is