]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/52181 (merge_decls doesn't handle DECL_USER_ALIGN properly)
authorJakub Jelinek <jakub@redhat.com>
Tue, 14 Feb 2012 23:34:34 +0000 (00:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 14 Feb 2012 23:34:34 +0000 (00:34 +0100)
Backported from mainline
2012-02-14  Jakub Jelinek  <jakub@redhat.com>

PR c/52181
* c-decl.c (merge_decls): Copy DECL_USER_ALIGN bit from olddecl to
newdecl.

* decl.c (duplicate_decls): If olddecl has bigger DECL_ALIGN than
newdecl, copy DECL_ALIGN to newdecl and or DECL_USER_ALIGN bits.

* c-c++-common/pr52181.c: New test.

From-SVN: r184242

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr52181.c [new file with mode: 0644]

index 48feadfadd0d4ae555fa71e781038e6ec1b74d6a..e458e08ac4eb2939e774d621bf759e2376f97b85 100644 (file)
@@ -1,6 +1,12 @@
 2012-02-14  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2012-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/52181
+       * c-decl.c (merge_decls): Copy DECL_USER_ALIGN bit from olddecl to
+       newdecl.
+
        2012-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        * cselib.c (dump_cselib_val): Don't assume l->setting_insn is
index b148f5e22f71e8fa58b618e278cdd7d33ffe1f2f..6d6331343290a3330405d9e8486944204188dcda 100644 (file)
@@ -2436,6 +2436,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
     memcpy ((char *) olddecl + sizeof (struct tree_common),
            (char *) newdecl + sizeof (struct tree_common),
            sizeof (struct tree_decl_common) - sizeof (struct tree_common));
+    DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
     switch (TREE_CODE (olddecl))
       {
       case FUNCTION_DECL:
index 15e93a5ed804b9c9af9c81964922f538c91bf48a..4eb9ec48954e2ae418dadcf77a9ff711aa02d74a 100644 (file)
@@ -1,3 +1,12 @@
+2012-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2012-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/52181
+       * decl.c (duplicate_decls): If olddecl has bigger DECL_ALIGN than
+       newdecl, copy DECL_ALIGN to newdecl and or DECL_USER_ALIGN bits.
+
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index a2e52613fce95988527e6852af1e778914923f23..6b6f158491eb6f4b1cbd8c910a1beac1ca83f793 100644 (file)
@@ -2154,7 +2154,12 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
       SET_DECL_INIT_PRIORITY (olddecl, DECL_INIT_PRIORITY (newdecl));
       DECL_HAS_INIT_PRIORITY_P (olddecl) = 1;
     }
-  /* Likewise for DECL_USER_ALIGN and DECL_PACKED.  */
+  /* Likewise for DECL_ALIGN, DECL_USER_ALIGN and DECL_PACKED.  */
+  if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
+    {
+      DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
+      DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
+    }
   DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl);
   if (TREE_CODE (newdecl) == FIELD_DECL)
     DECL_PACKED (olddecl) = DECL_PACKED (newdecl);
index 6e546a003aa474bdc7028b1c8fbde93915a08bad..2e19a3d73d510c8c679bdc95c9aab46dc0dd5684 100644 (file)
@@ -1,3 +1,11 @@
+2012-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2012-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/52181
+       * c-c++-common/pr52181.c: New test.
+
 2012-02-09  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/c-c++-common/pr52181.c b/gcc/testsuite/c-c++-common/pr52181.c
new file mode 100644 (file)
index 0000000..e09bc92
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c/52181 */
+/* { dg-do compile } */
+
+extern const int v1[];
+const int __attribute__((aligned(16))) v1[] = { 1 };
+extern const int __attribute__((aligned(16))) v2[];
+const int v2[] = { 1 };
+extern const int __attribute__((aligned(16))) v3[];
+const int __attribute__((aligned(16))) v3[] = { 1 };
+const int __attribute__((aligned(16))) v4[] = { 1 };
+int test[(__alignof__ (v4) != __alignof__ (v1)         /* { dg-bogus "is negative" } */
+        || __alignof__ (v4) != __alignof__ (v2)
+        || __alignof__ (v4) != __alignof__ (v3)) ? -1 : 0];