retrofit_lang_decl (decl);
SET_DECL_DEPENDENT_INIT_P (decl, true);
}
+
+ if (VAR_P (decl) && DECL_REGISTER (decl) && asmspec)
+ {
+ set_user_assembler_name (decl, asmspec);
+ DECL_HARD_REGISTER (decl) = 1;
+ }
return;
}
bool const_init = false;
unsigned int cnt = 0;
tree first = NULL_TREE, ndecl = error_mark_node;
+ tree asmspec_tree = NULL_TREE;
maybe_push_decl (decl);
if (VAR_P (decl)
now. */
predeclare_vla (decl);
- cp_finish_decl (decl, init, const_init, NULL_TREE, 0);
+ if (VAR_P (decl) && DECL_HARD_REGISTER (pattern_decl))
+ {
+ tree id = DECL_ASSEMBLER_NAME (pattern_decl);
+ const char *asmspec = IDENTIFIER_POINTER (id);
+ gcc_assert (asmspec[0] == '*');
+ asmspec_tree
+ = build_string (IDENTIFIER_LENGTH (id) - 1,
+ asmspec + 1);
+ TREE_TYPE (asmspec_tree) = char_array_type_node;
+ }
+
+ cp_finish_decl (decl, init, const_init, asmspec_tree, 0);
if (ndecl != error_mark_node)
cp_finish_decomp (ndecl, first, cnt);
--- /dev/null
+// PR c++/98847
+// { dg-do run }
+// { dg-options "-O2 -masm=att" }
+
+template <int N>
+int
+foo ()
+{
+ register int edx asm ("edx");
+ asm ("movl $1234, %%edx" : "=r" (edx));
+ return edx;
+}
+
+int
+main ()
+{
+ if (foo<0> () != 1234)
+ __builtin_abort ();
+ return 0;
+}