c++: Fix ICE with unexpanded parameter pack [PR99844]
In explicit17.C, we weren't detecting an unexpanded parameter pack in explicit(bool), so we crashed on a TEMPLATE_PARM_INDEX in constexpr. I noticed the same is true for noexcept(), but only since my patch to implement delayed parsing of noexcept. Previously, we would detect the unexpanded pack in push_template_decl but now the noexcept expression has not yet been parsed, so we need to do it a bit later. gcc/cp/ChangeLog: PR c++/99844 * decl.c (build_explicit_specifier): Call check_for_bare_parameter_packs. * except.c (build_noexcept_spec): Likewise. gcc/testsuite/ChangeLog: PR c++/99844 * g++.dg/cpp2a/explicit16.C: Use c++20. * g++.dg/cpp0x/noexcept66.C: New test. * g++.dg/cpp2a/explicit17.C: New test.
This commit is contained in:
parent
e34f88c955
commit
2cd5333d16
@ -17991,6 +17991,9 @@ require_deduced_type (tree decl, tsubst_flags_t complain)
|
|||||||
tree
|
tree
|
||||||
build_explicit_specifier (tree expr, tsubst_flags_t complain)
|
build_explicit_specifier (tree expr, tsubst_flags_t complain)
|
||||||
{
|
{
|
||||||
|
if (check_for_bare_parameter_packs (expr))
|
||||||
|
return error_mark_node;
|
||||||
|
|
||||||
if (instantiation_dependent_expression_p (expr))
|
if (instantiation_dependent_expression_p (expr))
|
||||||
/* Wait for instantiation, tsubst_function_decl will handle it. */
|
/* Wait for instantiation, tsubst_function_decl will handle it. */
|
||||||
return expr;
|
return expr;
|
||||||
|
|||||||
@ -1228,6 +1228,8 @@ type_throw_all_p (const_tree type)
|
|||||||
tree
|
tree
|
||||||
build_noexcept_spec (tree expr, tsubst_flags_t complain)
|
build_noexcept_spec (tree expr, tsubst_flags_t complain)
|
||||||
{
|
{
|
||||||
|
if (check_for_bare_parameter_packs (expr))
|
||||||
|
return error_mark_node;
|
||||||
if (TREE_CODE (expr) != DEFERRED_NOEXCEPT
|
if (TREE_CODE (expr) != DEFERRED_NOEXCEPT
|
||||||
&& !value_dependent_expression_p (expr))
|
&& !value_dependent_expression_p (expr))
|
||||||
{
|
{
|
||||||
|
|||||||
13
gcc/testsuite/g++.dg/cpp0x/noexcept66.C
Normal file
13
gcc/testsuite/g++.dg/cpp0x/noexcept66.C
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// PR c++/99844
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
template <bool... B>
|
||||||
|
struct S {
|
||||||
|
void fn() noexcept(B); // { dg-error "parameter packs not expanded" }
|
||||||
|
};
|
||||||
|
|
||||||
|
void fn ()
|
||||||
|
{
|
||||||
|
S<true> s;
|
||||||
|
s.fn();
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
// PR c++/95066 - explicit malfunction with dependent expression.
|
// PR c++/95066 - explicit malfunction with dependent expression.
|
||||||
// { dg-do compile { target c++2a } }
|
// { dg-do compile { target c++20 } }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Foo {
|
struct Foo {
|
||||||
|
|||||||
9
gcc/testsuite/g++.dg/cpp2a/explicit17.C
Normal file
9
gcc/testsuite/g++.dg/cpp2a/explicit17.C
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// PR c++/99844
|
||||||
|
// { dg-do compile { target c++20 } }
|
||||||
|
|
||||||
|
template <bool... B>
|
||||||
|
struct S {
|
||||||
|
constexpr explicit(B) S() {} // { dg-error "parameter packs not expanded" }
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr S<true> s;
|
||||||
Loading…
Reference in New Issue
Block a user