diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-12-23 11:17:45 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-12-23 11:17:45 -0500 |
commit | cf59c8983ef6590f0d69014f8dc8778b5b7691c6 (patch) | |
tree | fb47b0cec99431ab37908ad136ee3803accfc4e5 /gcc/testsuite | |
parent | 3d6bb832022160b00e7001ac5b467e201ab4a9ac (diff) | |
download | gcc-cf59c8983ef6590f0d69014f8dc8778b5b7691c6.zip gcc-cf59c8983ef6590f0d69014f8dc8778b5b7691c6.tar.gz gcc-cf59c8983ef6590f0d69014f8dc8778b5b7691c6.tar.bz2 |
c++: get_nsdmi in template context [PR108116]
Here during ahead of time checking of C{}, we indirectly call get_nsdmi
for C::m from finish_compound_literal, which in turn calls
break_out_target_exprs for C::m's (non-templated) initializer, during
which we build a call to A::~A and check expr_noexcept_p for it (from
build_vec_delete_1). But this is all done with processing_template_decl
set, so the built A::~A call is templated (whose form was recently
changed by r12-6897-gdec8d0e5fa00ceb2) which expr_noexcept_p doesn't
expect, and we crash.
This patch fixes this by clearing processing_template_decl before
the call to break_out_target_exprs from get_nsdmi. And since it more
generally seems we shouldn't be seeing (or producing) non-templated
trees in break_out_target_exprs, this patch also adds an assert to
that effect.
PR c++/108116
gcc/cp/ChangeLog:
* constexpr.cc (maybe_constant_value): Clear
processing_template_decl before calling break_out_target_exprs.
* init.cc (get_nsdmi): Likewise.
* tree.cc (break_out_target_exprs): Assert processing_template_decl
is cleared.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/nsdmi-template24.C: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nsdmi-template24.C | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template24.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template24.C new file mode 100644 index 0000000..202c67d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template24.C @@ -0,0 +1,22 @@ +// PR c++/108116 +// { dg-do compile { target c++11 } } + +#include <initializer_list> + +struct A { + A(int); + ~A(); +}; + +struct B { + B(std::initializer_list<A>); +}; + +struct C { + B m{0}; +}; + +template<class> +void f() { + C c = C{}; +}; |