@@ -7157,6 +7157,13 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
&& fndecl_built_in_p (decl, BUILT_IN_NORMAL))
set_builtin_user_assembler_name (decl, asmspec);
set_user_assembler_name (decl, asmspec);
+ if (DECL_LOCAL_DECL_P (decl))
+ if (auto ns_decl = DECL_LOCAL_DECL_ALIAS (decl))
+ /* We have to propagate the name to the ns-alias.
+ This is horrible, as we're affecting a
+ possibly-shared decl. Again, a one-true-decl
+ model breaks down. */
+ set_user_assembler_name (ns_decl, asmspec);
}
}
new file mode 100644
@@ -0,0 +1,20 @@
+// PR 99508, local exerns with aliased names
+// { dg-do link }
+int foo()
+{
+ void bar() asm ("bar_assembler");
+ extern unsigned buzz asm("buzz_assembler");
+ bar();
+ return buzz;
+}
+
+void ALIASbar () asm ("bar_assembler");
+void ALIASbar ()
+{
+}
+
+unsigned ALIASbuz asm ("buzz_assembler") = 5;
+
+int main ()
+{
+}