Commit 1740f8a1 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/63495 (struct __attribute__ ((aligned (8))) broken on x86)

	PR c/63495
	* stor-layout.c (min_align_of_type): Don't decrease alignment
	through BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN if
	TYPE_USER_ALIGN is set.

	* gcc.target/i386/pr63495.c: New test.

From-SVN: r216101
parent 878f5596
2014-10-10 Jakub Jelinek <jakub@redhat.com>
PR c/63495
* stor-layout.c (min_align_of_type): Don't decrease alignment
through BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN if
TYPE_USER_ALIGN is set.
2014-10-10 Uros Bizjak <ubizjak@gmail.com> 2014-10-10 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/63483 PR rtl-optimization/63483
...@@ -2400,17 +2400,19 @@ min_align_of_type (tree type) ...@@ -2400,17 +2400,19 @@ min_align_of_type (tree type)
{ {
unsigned int align = TYPE_ALIGN (type); unsigned int align = TYPE_ALIGN (type);
align = MIN (align, BIGGEST_ALIGNMENT); align = MIN (align, BIGGEST_ALIGNMENT);
if (!TYPE_USER_ALIGN (type))
{
#ifdef BIGGEST_FIELD_ALIGNMENT #ifdef BIGGEST_FIELD_ALIGNMENT
align = MIN (align, BIGGEST_FIELD_ALIGNMENT); align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
#endif #endif
unsigned int field_align = align; unsigned int field_align = align;
#ifdef ADJUST_FIELD_ALIGN #ifdef ADJUST_FIELD_ALIGN
tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, type);
type); field_align = ADJUST_FIELD_ALIGN (field, field_align);
field_align = ADJUST_FIELD_ALIGN (field, field_align); ggc_free (field);
ggc_free (field);
#endif #endif
align = MIN (align, field_align); align = MIN (align, field_align);
}
return align / BITS_PER_UNIT; return align / BITS_PER_UNIT;
} }
......
2014-10-10 Jakub Jelinek <jakub@redhat.com>
PR c/63495
* gcc.target/i386/pr63495.c: New test.
2014-10-10 Marek Polacek <polacek@redhat.com> 2014-10-10 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/object-size-1.c: New test. * c-c++-common/ubsan/object-size-1.c: New test.
......
/* PR c/63495 */
/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */
/* { dg-options "-std=gnu11" } */
struct __attribute__ ((aligned (8))) S { char c; };
_Static_assert (_Alignof (struct S) >= 8, "wrong alignment");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment