Bootstrapped and regtested on x86_64-pc-linux-gnu.  Also verified that
it fixes the regression on an mcore-elf cross.  OK for trunk?

-- >8 --

The assertion failure on ASM_OUTPUT_WEAKREF targets since my r16-1738
was caused because the 'TREE_CHAIN (id)' check in assemble_name_resolve
no longer implies that ID is a transparent alias, since internal
identifiers can have a TREE_CHAIN as well.

I still don't think it's possible for a transparent alias to be an
internal identifier in the sense added, so this patch simply constrains
the assertion better so that it doesn't spuriously fail.  I also added a
couple of other assertions to help validate this assumption.

gcc/ChangeLog:

        * cgraphunit.cc (symbol_table::compile): Assert a transparent
        alias is not an internal identifier.
        * symtab.cc (symbol_table::change_decl_assembler_name):
        Likewise.
        * varasm.cc (assemble_name_resolve): Check for
        IDENTIFIER_TRANSPARENT_ALIAS instead of just TREE_CHAIN.

Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
---
 gcc/cgraphunit.cc | 7 ++++---
 gcc/symtab.cc     | 1 +
 gcc/varasm.cc     | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index 8e8d85562b0..9f4af63b7dc 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -2400,9 +2400,10 @@ symbol_table::compile (void)
     if (node->alias
        && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->decl)))
       {
-       IDENTIFIER_TRANSPARENT_ALIAS
-          (DECL_ASSEMBLER_NAME (node->decl)) = 1;
-       TREE_CHAIN (DECL_ASSEMBLER_NAME (node->decl))
+       tree id = DECL_ASSEMBLER_NAME (node->decl);
+       gcc_assert (!IDENTIFIER_INTERNAL_P (id));
+       IDENTIFIER_TRANSPARENT_ALIAS (id) = 1;
+       TREE_CHAIN (id)
           = (node->alias_target ? node->alias_target
              : DECL_ASSEMBLER_NAME (node->get_alias_target ()->decl));
       }
diff --git a/gcc/symtab.cc b/gcc/symtab.cc
index fc1155f4696..652f66a5d2f 100644
--- a/gcc/symtab.cc
+++ b/gcc/symtab.cc
@@ -305,6 +305,7 @@ symbol_table::change_decl_assembler_name (tree decl, tree 
name)
       SET_DECL_ASSEMBLER_NAME (decl, name);
       if (alias)
        {
+         gcc_assert (!IDENTIFIER_INTERNAL_P (name));
          IDENTIFIER_TRANSPARENT_ALIAS (name) = 1;
          TREE_CHAIN (name) = alias;
        }
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 10c1d2e3137..5dd99f5aeff 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -2907,7 +2907,7 @@ assemble_name_resolve (const char *name)
       ultimate_transparent_alias_target (&id);
       if (id != id_orig)
        name = IDENTIFIER_POINTER (id);
-      gcc_assert (! TREE_CHAIN (id));
+      gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (id));
     }
 
   return name;
-- 
2.47.0

Reply via email to