From cc2c33286fdfb60c71940f39674e731766675f90 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 3 Mar 2002 01:00:51 -0800 Subject: [PATCH] * c-decl.c (start_decl): Initialized variables are not common. From-SVN: r50250 --- gcc/c-decl.c | 2 +- gcc/testsuite/gcc.c-torture/compile/20020303-1.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20020303-1.c diff --git a/gcc/c-decl.c b/gcc/c-decl.c index f465875..845cefb 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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 index 0000000..a120adf --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20020303-1.c @@ -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; -- 2.7.4