re PR c++/57945 (ICE: in varpool_get_node, at cgraph.h:840)
authorJakub Jelinek <jakub@gcc.gnu.org>
Fri, 17 Jan 2014 14:19:55 +0000 (15:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 17 Jan 2014 14:19:55 +0000 (15:19 +0100)
PR c++/57945
* passes.c (rest_of_decl_compilation): Don't call varpool_finalize_decl
on decls for which assemble_alias has been called.

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

From-SVN: r206708

gcc/ChangeLog
gcc/passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/pr57945.c [new file with mode: 0644]

index f6b76927cc29f89c1468530583282959224ae9e0..239d6d6d6298ae4e48e204720304dd3e09d5e862 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-17  Jan Hubicka  <hubicka@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  Nick Clifton  <nickc@redhat.com>
 
        * config/msp430/msp430.opt: (mcpu): New option.
index 3b340d3a5463f57d919094d425f6a28d7ba598b0..60fb13536fa60fcb3acf3101940bf3afb8ae86e5 100644 (file)
@@ -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);
        }
 
index 665d9034d276e98a260e12d51b9ecf664e0677f4..b5c9a2521d062205e9c6bc529c3b164c6a2d2fcb 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/57945
+       * c-c++-common/torture/pr57945.c: New test.
+
 2014-01-17  Zhenqiang Chen  <zhenqiang.chen@arm.com>
 
        * gcc.target/arm/its.c: New testcase.
diff --git a/gcc/testsuite/c-c++-common/torture/pr57945.c b/gcc/testsuite/c-c++-common/torture/pr57945.c
new file mode 100644 (file)
index 0000000..0803e8f
--- /dev/null
@@ -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;
+}