re PR bootstrap/34003 (gcc trunk unable to bootstrap itself; Unsatisfied symbols...
authorJakub Jelinek <jakub@redhat.com>
Sat, 15 Dec 2007 23:08:47 +0000 (00:08 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 15 Dec 2007 23:08:47 +0000 (00:08 +0100)
PR bootstrap/34003
* c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.
* config/pa/pa.c (pa_encode_section_info): If !first, preserve
SYMBOL_FLAG_REFERENCED flag.

* gcc.dg/pr34003-1.c: New test.
* gcc.dg/pr34003-2.c: New.

From-SVN: r130979

gcc/ChangeLog
gcc/c-decl.c
gcc/config/pa/pa.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr34003-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr34003-2.c [new file with mode: 0644]

index dc72887a10cc3ed9fba69f16d8472e65dba1106a..054ef8f2caf4f413e54530574f57f9fbd4b0885f 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR bootstrap/34003
+       * c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.
+       * config/pa/pa.c (pa_encode_section_info): If !first, preserve
+       SYMBOL_FLAG_REFERENCED flag.
+
 2007-12-15  Alexandre Oliva  <aoliva@redhat.com>
 
        * tree.c (type_hash_add): Fix whitespace.
index 1da57c2c998202d579cf4730d20245b1cd7c2399..033ff2eec49af527a2f6f0106ff7d915e489c181 100644 (file)
@@ -1670,6 +1670,9 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
        }
     }
 
+  /* Keep the old rtl since we can safely use it.  */
+  if (HAS_RTL_P (olddecl))
+    COPY_DECL_RTL (olddecl, newdecl);
 
   /* Merge the type qualifiers.  */
   if (TREE_READONLY (newdecl))
index b1f3a0036532b1cce85b2ad829761a6016119840..b4d890c930c45b49db5890e7be2c2491c4f2abd5 100644 (file)
@@ -7834,6 +7834,12 @@ hppa_encode_label (rtx sym)
 static void
 pa_encode_section_info (tree decl, rtx rtl, int first)
 {
+  int old_referenced = 0;
+
+  if (!first && MEM_P (rtl) && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF)
+    old_referenced
+      = SYMBOL_REF_FLAGS (XEXP (rtl, 0)) & SYMBOL_FLAG_REFERENCED;
+
   default_encode_section_info (decl, rtl, first);
 
   if (first && TEXT_SPACE_P (decl))
@@ -7842,6 +7848,8 @@ pa_encode_section_info (tree decl, rtx rtl, int first)
       if (TREE_CODE (decl) == FUNCTION_DECL)
        hppa_encode_label (XEXP (rtl, 0));
     }
+  else if (old_referenced)
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= old_referenced;
 }
 
 /* This is sort of inverse to pa_encode_section_info.  */
index 3ceb531d389ca9910d6feb8fefe6489387f1ec47..b3dc9af7765072f879836ff8db17344e1ab10ef8 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR bootstrap/34003
+       * gcc.dg/pr34003-1.c: New test.
+       * gcc.dg/pr34003-2.c: New.
+
 2007-12-15  Hans-Peter Nilsson  <hp@axis.com>
 
        * gcc.target/cris/peep2-xsrand.c, gcc.target/cris/asmreg-1.c,
diff --git a/gcc/testsuite/gcc.dg/pr34003-1.c b/gcc/testsuite/gcc.dg/pr34003-1.c
new file mode 100644 (file)
index 0000000..ff97fe6
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR bootstrap/34003 */
+/* { dg-do link } */
+/* { dg-options "-O0" } */
+/* { dg-additional-sources "pr34003-2.c" } */
+
+extern void foo (void);
+int bar (void) { foo (); return 1; }
+extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/pr34003-2.c b/gcc/testsuite/gcc.dg/pr34003-2.c
new file mode 100644 (file)
index 0000000..a533056
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR bootstrap/34003 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+extern void abort (void);
+
+int seen = 0;
+
+void foo (void)
+{
+  ++seen;
+}
+
+int main (void)
+{
+  extern int bar (void);
+  if (bar () != 1 || seen != 1)
+    abort ();
+  return 0;
+}