Hi,
the testcase bellow manages to corrupt IPA-REF reference lists.
The problem is that C++ FE creates new symtab node while another is in 
construction
via DECL_ASSEMBLER_NAME hook.

Bootstrapped/regtested/comitted x86_64-linux.
Honza

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 187797)
+++ ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2012-05-22  Jan Hubicka  <j...@suse.cz>
+
+       PR middle-end/53161
+       * symtab.c (symtab_register_node): Fix ordering issue.
+
 2012-05-22  Steven Drake <s...@netbsd.org>
 
        * gcc.c (do_spec_1): Add %M spec token to output multilib_os_dir.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 187797)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2012-05-22  Jan Hubicka  <j...@suse.cz>
+
+       PR middle-end/53161
+       * g++.dg/torture/pr53161.C: New testcase.
+
 2012-05-22  Tobias Burnus  <bur...@net-b.de>
 
        PR fortran/53389
Index: testsuite/g++.dg/torture/pr53161.C
===================================================================
--- testsuite/g++.dg/torture/pr53161.C  (revision 0)
+++ testsuite/g++.dg/torture/pr53161.C  (revision 0)
@@ -0,0 +1,22 @@
+/* { dg-options "-std=c++11" } */
+void gg();
+static __typeof(gg) __gthrw_gg __attribute__((__weakref__("gg")));
+
+template<typename R,typename... A>
+struct data {
+ template<typename Y,typename X>
+ data(Y& y,R(X::*f)(A...));
+};
+
+template<typename Y,typename X,typename R,typename... A>
+data<R,A...> make_data(Y& y,R(X::*f)(A...)) {
+ return data<R,A...>(y,f);
+}
+
+void global(data<void>);
+
+struct test {
+ void bar() {}
+ void doit() { global(make_data(*this,&test::bar)); }
+};
+
Index: symtab.c
===================================================================
--- symtab.c    (revision 187695)
+++ symtab.c    (working copy)
@@ -177,11 +177,13 @@ symtab_register_node (symtab_node node)
   if (*slot == NULL)
     *slot = node;
 
-  insert_to_assembler_name_hash (node);
+  ipa_empty_ref_list (&node->symbol.ref_list);
 
   node->symbol.order = symtab_order++;
 
-  ipa_empty_ref_list (&node->symbol.ref_list);
+  /* Be sure to do this last; C++ FE might create new nodes via
+     DECL_ASSEMBLER_NAME langhook!  */
+  insert_to_assembler_name_hash (node);
 }
 
 /* Make NODE to be the one symtab hash is pointing to.  Used when reshaping 
tree

Reply via email to