OSDN Git Service

* varasm.c (make_decl_rtl): Don't allow weak variables to be
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 May 2002 18:11:04 +0000 (18:11 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 May 2002 18:11:04 +0000 (18:11 +0000)
placed in common.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53798 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/weak-8.c [new file with mode: 0644]
gcc/varasm.c

index fb3802d..f90aa47 100644 (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
index 573f339..fb03406 100644 (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
diff --git a/gcc/testsuite/gcc.dg/weak-8.c b/gcc/testsuite/gcc.dg/weak-8.c
new file mode 100644 (file)
index 0000000..9cfb517
--- /dev/null
@@ -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;
+}
index a055bbf..8a7f949 100644 (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).