varasm.c (make_decl_rtl): Don't allow weak variables to be placed in common.

* varasm.c (make_decl_rtl): Don't allow weak variables to be
	placed in common.

	* gcc/testsuite/gcc.dg/weak-8.c: New test.

From-SVN: r53798
This commit is contained in:
Mark Mitchell 2002-05-23 18:11:04 +00:00 committed by Mark Mitchell
parent 0f72964f10
commit 5ff225fc29
4 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2002-05-23 Mark Mitchell <mark@codesourcery.com>
* varasm.c (make_decl_rtl): Don't allow weak variables to be
placed in common.
Thu May 23 19:43:41 CEST 2002 Jan Hubicka <jh@suse.cz>
* cfg.c (dump_flow_info): Print results of

View File

@ -1,3 +1,7 @@
2002-05-23 Mark Mitchell <mark@codesourcery.com>
* gcc/testsuite/gcc.dg/weak-8.c: New test.
Thu May 23 11:09:26 2002 J"orn Rennecke <joern.rennecke@superh.com>
* gcc.dg/weak-2.c: Allow optional leading underscore

View File

@ -0,0 +1,10 @@
/* { dg-do assemble } */
/* COFF does not support weak, and dg doesn't support UNSUPPORTED. */
/* { dg-do assemble { xfail *-*-coff i?86-pc-cygwin h8300-*-hms } } */
__attribute__ ((weak)) int i;
int f() {
return i;
}

View File

@ -922,6 +922,10 @@ make_decl_rtl (decl, asmspec)
&& DECL_COMMON (decl))
DECL_COMMON (decl) = 0;
/* Variables can't be both common and weak. */
if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl))
DECL_COMMON (decl) = 0;
/* Can't use just the variable's own name for a variable
whose scope is less than the whole file, unless it's a member
of a local class (which will already be unambiguous).