[c++] Adjust mark used member in instantiated class scope
authorNathan Sidwell <nathan@acm.org>
Tue, 4 Jan 2022 21:36:44 +0000 (13:36 -0800)
committerNathan Sidwell <nathan@acm.org>
Wed, 5 Jan 2022 12:13:56 +0000 (04:13 -0800)
commitb1e701dc4adb11a5ed5f45c2fb31ba4689b718d0
tree6fcf71bb828c4c3bbcac68230ab96813ef6071de
parentf2da9e26f5c0f04d48872938eff130e2028e75d3
[c++] Adjust mark used member in instantiated class scope

The fix for PR97966 caused a regression with (non-template) member
functions of template classes.  We need to mark them used in the
instantiated class's scope, rather than the scope we were in before
instantiating, as the latter may itself be in template and change the
behaviour of marking a function as used.

gcc/cp/
* pt.c (instantiate_class_template_1): Process attribute((used)) set
in class's context.
gcc/testsuite/
* g++.dg/template/attr-used.C: New.
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/attr-used.C [new file with mode: 0644]