PR c/63495
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Oct 2014 17:43:21 +0000 (17:43 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Oct 2014 17:43:21 +0000 (17:43 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216101 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/stor-layout.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr63495.c [new file with mode: 0644]

index d418235..55c99d4 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
        PR rtl-optimization/63483
index 8328326..eefc52a 100644 (file)
@@ -2400,17 +2400,19 @@ min_align_of_type (tree type)
 {
   unsigned int align = TYPE_ALIGN (type);
   align = MIN (align, BIGGEST_ALIGNMENT);
+  if (!TYPE_USER_ALIGN (type))
+    {
 #ifdef BIGGEST_FIELD_ALIGNMENT
-  align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
+      align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
 #endif
-  unsigned int field_align = align;
+      unsigned int field_align = align;
 #ifdef ADJUST_FIELD_ALIGN
-  tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
-                          type);
-  field_align = ADJUST_FIELD_ALIGN (field, field_align);
-  ggc_free (field);
+      tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE, type);
+      field_align = ADJUST_FIELD_ALIGN (field, field_align);
+      ggc_free (field);
 #endif
-  align = MIN (align, field_align);
+      align = MIN (align, field_align);
+    }
   return align / BITS_PER_UNIT;
 }
 
index b8cd638..e77c6a1 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * c-c++-common/ubsan/object-size-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr63495.c b/gcc/testsuite/gcc.target/i386/pr63495.c
new file mode 100644 (file)
index 0000000..7f02f37
--- /dev/null
@@ -0,0 +1,6 @@
+/* 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");