re PR target/49551 (tentative declaration after definition and -fdata-sections cause...
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Tue, 2 Jun 2015 16:42:27 +0000 (16:42 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Tue, 2 Jun 2015 16:42:27 +0000 (16:42 +0000)
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.

From-SVN: r224033

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr49551.c [new file with mode: 0644]

index bcad7b7b826ec879ddfd629d9ab47ee29bb39bf9..20122e60f9e5bb17f6aa26e3318642e3d4e78a69 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-02  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR c/49551
+       * c-decl.c (merge_decls): Merge DECL_COMMON.
+
 2015-05-22  Jim Wilson  <jim.wilson@linaro.org>
 
        * Make-lang.in (check_gcc_pallelize): Define.
index a2edefc5f340422a8d187cdb5495c64cbe251649..68c79df63e6fc0231b0efea4268491a3ec516007 100644 (file)
@@ -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).  */
index 4dd3014c91e61d4e2b28905aec8a6e76623a15b8..5060c5339449c4e1bdc47df403190f1759019d54 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-02  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR c/49551
+       * gcc.dg/pr49551.c: New testcase.
+
 2015-06-02  Richard Biener  <rguenther@suse.de>
 
        PR debug/65549
diff --git a/gcc/testsuite/gcc.dg/pr49551.c b/gcc/testsuite/gcc.dg/pr49551.c
new file mode 100644 (file)
index 0000000..204f06d
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdata-sections" } */
+
+int x = 1;
+int x;
+
+/* { dg-final { scan-assembler-not {comm[\t ]+x} } } */