c++: subst failure in attribute argument [PR95192]
authorJason Merrill <jason@redhat.com>
Mon, 1 Feb 2021 22:24:05 +0000 (17:24 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 4 Feb 2021 02:38:33 +0000 (21:38 -0500)
commit7b258ac7afaaf7d8157df10ea35c6002d935d7d0
tree36614d6f4de83622d092a3b5813394ffa9ba807b
parent9faaa80776a3dd602b47555bc001ca9a6ac6b784
c++: subst failure in attribute argument [PR95192]

Another SFINAE issue: we weren't propagating substitution failure in
attributes back up.  And tsubst_function_decl needs to check substitution
before register_specialization.  I thought about moving the other error
returns up as well, but they aren't SFINAE cases, so they can stay where
they are.

This change caused pr84630.C to stop giving an error; this was because
partial instantiation of the lambda failed silently, and before the change
that meant error_mark_node passed to decl_attributes, which complained about
there being an argument at all.  With the change the partial instantiation
fails, but no error was ever given, because push_template_decl silently
failed if current_template_parms wasn't set.  So let's set c_t_p
appropriately.  lambda-uneval13.C is a valid testcase to exercise this.

gcc/cp/ChangeLog:

PR c++/95192
* pt.c (tsubst_attribute): Handle error.
(apply_late_template_attributes): Return false on error.
(tsubst_function_decl): Check its return value.
(tsubst_decl): Likewise.
(push_template_decl): Assert current_template_parms.
(tsubst_template_decl): Set current_template_parms.

gcc/testsuite/ChangeLog:

PR c++/95192
* g++.dg/cpp0x/pr84630.C: Call b().
* g++.dg/cpp2a/lambda-uneval13.C: New test.
* g++.dg/ext/attr-expr1.C: New test.
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/pr84630.C
gcc/testsuite/g++.dg/cpp2a/lambda-uneval13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/attr-expr1.C [new file with mode: 0644]