summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-14 06:15:35 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-14 06:15:35 +0000
commitfc0d4990130cd9e678544f52530e7bbc4427dd57 (patch)
tree8eb32a64dbd1fd610d6b8ec9aceff9719e62f75f
parent088dac04d2c47df50120194739a7995dbfd14ee6 (diff)
downloadgcc-fc0d4990130cd9e678544f52530e7bbc4427dd57.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184193 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-decl.c3
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr52181.c13
6 files changed, 39 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e6dd0ca1372..b297a6d0984 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR bootstrap/52172
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 4825c7e83d6..93fb16d71ff 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1,6 +1,6 @@
/* Process declarations and variables for C compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GCC.
@@ -2449,6 +2449,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:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f9246e56b74..668066831ec 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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-07 Jason Merrill <jason@redhat.com>
PR c++/51675
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7fba04ab9f1..8fcfbd5a215 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1,6 +1,6 @@
/* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -2214,7 +2214,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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 207e5cf5e88..bd0b6386071 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-02-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/52181
+ * c-c++-common/pr52181.c: New test.
+
2012-02-13 Jakub Jelinek <jakub@redhat.com>
PR c++/52215
diff --git a/gcc/testsuite/c-c++-common/pr52181.c b/gcc/testsuite/c-c++-common/pr52181.c
new file mode 100644
index 00000000000..e09bc92fc6f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr52181.c
@@ -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];