Hi!

I've bootstrapped/regtested on x86_64-linux and i686-linux
following patch from Honza from the PR comment (written a month
ago, acked by Jason a fortnight ago) and committed it to trunk.

2014-01-17  Jan Hubicka  <hubi...@ucw.cz>

        PR c++/57945
        * passes.c (rest_of_decl_compilation): Don't call varpool_finalize_decl
        on decls for which assemble_alias has been called.

2014-01-17  Jakub Jelinek  <ja...@redhat.com>

        PR c++/57945
        * c-c++-common/torture/pr57945.c: New test.

--- gcc/passes.c.jj     2014-01-03 11:41:01.000000000 +0100
+++ gcc/passes.c        2014-01-17 11:51:15.767231295 +0100
@@ -187,6 +187,8 @@ rest_of_decl_compilation (tree decl,
                          int top_level,
                          int at_end)
 {
+  bool finalize = true;
+
   /* We deferred calling assemble_alias so that we could collect
      other attributes such as visibility.  Emit the alias now.  */
   if (!in_lto_p)
@@ -203,6 +205,7 @@ rest_of_decl_compilation (tree decl,
        DECL_EXTERNAL (decl) = 0;
        TREE_STATIC (decl) = 1;
        assemble_alias (decl, alias);
+       finalize = false;
       }
   }
 
@@ -234,7 +237,7 @@ rest_of_decl_compilation (tree decl,
             rebuild it.  */
          if (in_lto_p && !at_end)
            ;
-         else if (TREE_CODE (decl) != FUNCTION_DECL)
+         else if (finalize && TREE_CODE (decl) != FUNCTION_DECL)
            varpool_finalize_decl (decl);
        }
 
--- gcc/testsuite/c-c++-common/torture/pr57945.c.jj     2014-01-17 
11:52:02.384990286 +0100
+++ gcc/testsuite/c-c++-common/torture/pr57945.c        2014-01-17 
11:50:03.000000000 +0100
@@ -0,0 +1,11 @@
+/* PR c++/57945 */
+/* { dg-do compile } */
+
+extern int j;
+static int i __attribute__((weakref("j")));
+
+int
+foo (void)
+{
+  return &i ? i : 0;
+}

        Jakub

Reply via email to