* c-decl.c (start_decl): Initialized variables are not common.
authorRichard Henderson <rth@gcc.gnu.org>
Sun, 3 Mar 2002 09:00:51 +0000 (01:00 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 3 Mar 2002 09:00:51 +0000 (01:00 -0800)
From-SVN: r50250

gcc/c-decl.c
gcc/testsuite/gcc.c-torture/compile/20020303-1.c [new file with mode: 0644]

index f465875a909cf2554a1b1798be9082ae94f2bf0f..845cefba56049a4f094d4e395efe86fc885ceab6 100644 (file)
@@ -3476,7 +3476,7 @@ start_decl (declarator, declspecs, initialized, attributes)
      initializer equal to zero.  (Section 3.7.2)
      -fno-common gives strict ANSI behavior.  Usually you don't want it.
      This matters only for variables with external linkage.  */
-  if (! flag_no_common || ! TREE_PUBLIC (decl))
+  if (!initialized && (! flag_no_common || ! TREE_PUBLIC (decl)))
     DECL_COMMON (decl) = 1;
 
   /* Set attributes here so if duplicate decl, will have proper attributes.  */
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020303-1.c b/gcc/testsuite/gcc.c-torture/compile/20020303-1.c
new file mode 100644 (file)
index 0000000..a120adf
--- /dev/null
@@ -0,0 +1,5 @@
+/* With -fzero-initialized-in-bss, we made I a common symbol instead
+   of a symbol in the .bss section.  Not only does that break semantics,
+   but a common symbol can't be weak.  */
+
+int i __attribute__((weak)) = 0;