diff options
author | Marek Polacek <polacek@redhat.com> | 2022-10-11 14:16:54 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-10-13 11:01:17 -0400 |
commit | 3130e70dab1e64a7b014391fe941090d5f3b6b7d (patch) | |
tree | 9ceab2489a743e7fa3e9429bc67e7ca9ee404878 /gcc/cp | |
parent | e5139d18dfb8130876ea59178e8471fb1b34bb80 (diff) | |
download | gcc-3130e70dab1e64a7b014391fe941090d5f3b6b7d.zip gcc-3130e70dab1e64a7b014391fe941090d5f3b6b7d.tar.gz gcc-3130e70dab1e64a7b014391fe941090d5f3b6b7d.tar.bz2 |
c++: ICE with VEC_INIT_EXPR and defarg [PR106925]
Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr
while processing the default argument in this test. At this point
start_preparsed_function hasn't yet set current_function_decl.
expand_vec_init_expr then leads to maybe_splice_retval_cleanup which
checks DECL_CONSTRUCTOR_P (current_function_decl) without checking that
c_f_d is non-null first. It seems correct that c_f_d is null here, so
it seems to me that maybe_splice_retval_cleanup should check c_f_d as
in the following patch.
PR c++/106925
gcc/cp/ChangeLog:
* except.cc (maybe_splice_retval_cleanup): Check current_function_decl.
Make the bool const.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-defarg3.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/except.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc index 703d1d5..2677a9b 100644 --- a/gcc/cp/except.cc +++ b/gcc/cp/except.cc @@ -1307,9 +1307,12 @@ maybe_splice_retval_cleanup (tree compound_stmt) { /* If we need a cleanup for the return value, add it in at the same level as pushdecl_outermost_localscope. And also in try blocks. */ - bool function_body + const bool function_body = (current_binding_level->level_chain - && current_binding_level->level_chain->kind == sk_function_parms); + && current_binding_level->level_chain->kind == sk_function_parms + /* When we're processing a default argument, c_f_d may not have been + set. */ + && current_function_decl); if ((function_body || current_binding_level->kind == sk_try) && !DECL_CONSTRUCTOR_P (current_function_decl) |