Skip to content

Commit 4a8fd4a

Browse files
committed
Prevent mixups of IDENTIFIER_TRANSPARENT_ALIAS and IDENTIFIER_INTERNAL_P better [PR120855]
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 fail spuriously. I also added a couple of other assertions to help validate this assumption. PR middle-end/120855 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 <[email protected]> Reviewed-by: Jason Merrill <[email protected]>
1 parent 68ddec9 commit 4a8fd4a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

gcc/cgraphunit.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,9 +2400,10 @@ symbol_table::compile (void)
24002400
if (node->alias
24012401
&& lookup_attribute ("weakref", DECL_ATTRIBUTES (node->decl)))
24022402
{
2403-
IDENTIFIER_TRANSPARENT_ALIAS
2404-
(DECL_ASSEMBLER_NAME (node->decl)) = 1;
2405-
TREE_CHAIN (DECL_ASSEMBLER_NAME (node->decl))
2403+
tree id = DECL_ASSEMBLER_NAME (node->decl);
2404+
gcc_assert (!IDENTIFIER_INTERNAL_P (id));
2405+
IDENTIFIER_TRANSPARENT_ALIAS (id) = 1;
2406+
TREE_CHAIN (id)
24062407
= (node->alias_target ? node->alias_target
24072408
: DECL_ASSEMBLER_NAME (node->get_alias_target ()->decl));
24082409
}

gcc/symtab.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ symbol_table::change_decl_assembler_name (tree decl, tree name)
305305
SET_DECL_ASSEMBLER_NAME (decl, name);
306306
if (alias)
307307
{
308+
gcc_assert (!IDENTIFIER_INTERNAL_P (name));
308309
IDENTIFIER_TRANSPARENT_ALIAS (name) = 1;
309310
TREE_CHAIN (name) = alias;
310311
}

gcc/varasm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ assemble_name_resolve (const char *name)
29082908
ultimate_transparent_alias_target (&id);
29092909
if (id != id_orig)
29102910
name = IDENTIFIER_POINTER (id);
2911-
gcc_assert (! TREE_CHAIN (id));
2911+
gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (id));
29122912
}
29132913

29142914
return name;

0 commit comments

Comments
 (0)