Hi!

Last year I've added cgraph_node::get_create calls for the dummy
functions used for -fdump-passes, so that it interacts well with pass
disabling/enabling which is cgraph uid based.
Unfortunately, as the following testcase shows, when assembler hash
is present, that wants to compute DECL_ASSEMBLER_NAME and the C++ FE
is unprepared to handle it on the dummy functions which don't have
DECL_NAME etc.
The following patch fixes it by setting up a dummy DECL_ASSEMBLER_NAME
on these, so that the FEs don't need to compute it.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2021-05-18  Jakub Jelinek  <ja...@redhat.com>

        PR c++/100580
        * function.c (push_dummy_function): Set DECL_ARTIFICIAL and
        DECL_ASSEMBLER_NAME on the fn_decl.

        * g++.dg/other/pr100580.C: New test.

--- gcc/function.c.jj   2021-01-09 10:48:11.959312213 +0100
+++ gcc/function.c      2021-05-17 17:41:41.489047441 +0200
@@ -4930,6 +4930,9 @@ push_dummy_function (bool with_decl)
       fn_result_decl = build_decl (UNKNOWN_LOCATION, RESULT_DECL,
                                         NULL_TREE, void_type_node);
       DECL_RESULT (fn_decl) = fn_result_decl;
+      DECL_ARTIFICIAL (fn_decl) = 1;
+      tree fn_name = get_identifier (" ");
+      SET_DECL_ASSEMBLER_NAME (fn_decl, fn_name);
     }
   else
     fn_decl = NULL_TREE;
--- gcc/testsuite/g++.dg/other/pr100580.C.jj    2021-05-17 19:10:24.900331571 
+0200
+++ gcc/testsuite/g++.dg/other/pr100580.C       2021-05-17 19:10:04.761553670 
+0200
@@ -0,0 +1,8 @@
+// PR c++/100580
+// { dg-do compile }
+// { dg-require-weak "" }
+// { dg-options "-fdump-passes" }
+// { dg-prune-output ".*" }
+
+int foo;
+static __typeof(foo) bar __attribute__((__weakref__("foo")));

        Jakub

Reply via email to