summaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-02 16:42:27 +0000
committerprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-02 16:42:27 +0000
commit5b9761f58bf4e15d10c7c22918decda9ea9463ba (patch)
tree867e9b53f899e2be842a020973ebfb68ddb838ef /gcc/c/c-decl.c
parentea589ea6bf9a979c9d1af1242034b8ab0d103d52 (diff)
downloadgcc-5b9761f58bf4e15d10c7c22918decda9ea9463ba.tar.gz
2015-06-02 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR c/49551 * c-decl.c (merge_decls): Merge DECL_COMMON. * gcc.dg/pr49551.c: New test-case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224033 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index a2edefc5f34..68c79df63e6 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -2631,6 +2631,12 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
else if (DECL_PRESERVE_P (newdecl))
DECL_PRESERVE_P (olddecl) = 1;
+ /* Merge DECL_COMMON */
+ if (VAR_P (olddecl) && VAR_P (newdecl)
+ && !lookup_attribute ("common", DECL_ATTRIBUTES (newdecl))
+ && !lookup_attribute ("nocommon", DECL_ATTRIBUTES (newdecl)))
+ DECL_COMMON (newdecl) = DECL_COMMON (newdecl) && DECL_COMMON (olddecl);
+
/* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
But preserve OLDDECL's DECL_UID, DECL_CONTEXT and
DECL_ARGUMENTS (if appropriate). */