]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847]
authorJakub Jelinek <jakub@redhat.com>
Thu, 28 Jan 2021 15:13:11 +0000 (16:13 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 22 Apr 2021 14:18:51 +0000 (16:18 +0200)
commit712ffc0ad150aadfa5b91f493075e88fd050189f
treebb78d21eacf187875c178d449476a49d117100f1
parent4e4a5809586a345e12aed7a65e89551d6bdfbda3
c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.dg/opt/pr98847.C: New test.

(cherry picked from commit cf93f94b3498f3925895fb0bbfd4b64232b9987a)
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/opt/pr98847.C [new file with mode: 0644]