c++ comment adjustments for 114935

gcc/cp/ChangeLog:

	* decl.cc (wrap_cleanups_r): Clarify comment.
	* init.cc (build_vec_init): Update comment.
This commit is contained in:
Jason Merrill 2024-05-14 17:37:08 -04:00
parent fc559584fa
commit 1288283051
2 changed files with 13 additions and 7 deletions

View file

@ -8028,11 +8028,11 @@ wrap_cleanups_r (tree *stmt_p, int *walk_subtrees, void *data)
Unfortunately, there's no way to express this properly in terms of
nesting, as the regions for the temporaries overlap the region for the
variable itself; if there are two temporaries, the variable needs to be
the first thing destroyed if either of them throws. However, we only
want to run the variable's cleanup if it actually got constructed. So
we need to guard the temporary cleanups with the variable's cleanup if
they are run on the normal path, but not if they are run on the
exceptional path. We implement this by telling
the first thing destroyed if either of the temporary destructors throws.
However, we only want to run the variable's cleanup if it actually got
constructed. So we need to guard the temporary cleanups with the
variable's cleanup if they are run on the normal path, but not if they
are run on the exceptional path. We implement this by telling
honor_protect_cleanup_actions to strip the variable cleanup from the
exceptional path.

View file

@ -4685,8 +4685,14 @@ build_vec_init (tree base, tree maxindex, tree init,
for any temporaries in the initialization are naturally within our
cleanup region, so we don't want wrap_temporary_cleanups to do
anything for arrays. But if the array is a subobject, we need to
tell split_nonconstant_init how to turn off this cleanup in favor of
the cleanup for the complete object. */
tell split_nonconstant_init or cp_genericize_target_expr how to turn
off this cleanup in favor of the cleanup for the complete object.
??? For an array temporary such as an initializer_list backing array,
it would avoid redundancy to leave this cleanup active, clear
CLEANUP_EH_ONLY, and not build another cleanup for the temporary
itself. But that breaks when gimplify_target_expr adds a clobber
cleanup that runs before the build_vec_init cleanup. */
if (cleanup_flags)
vec_safe_push (*cleanup_flags, build_tree_list (iterator, maxindex));
}