https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108880

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #12)
> Sure, it worked for the testcase because the STATEMENT_LIST only had two
> stmts.  I'm testing:
> 
> --- a/gcc/c-family/c-gimplify.cc
> +++ b/gcc/c-family/c-gimplify.cc
> @@ -516,7 +516,8 @@ c_genericize_control_stmt (tree *stmt_p, int
> *walk_subtrees, void *data,
>           tree t = tsi_stmt (i);
>           if (TREE_CODE (t) != DEBUG_BEGIN_STMT && nondebug_stmts < 2)
>         nondebug_stmts++;
> -         walk_tree_1 (tsi_stmt_ptr (i), func, data, NULL, lh);
> +         walk_tree_1 (tsi_stmt_ptr (i), func, data,
> +              static_cast<hash_set<tree> *>(data), lh);

I'd limit this change to !c_dialect_cxx () only, I'm afraid if it is done
for C++ too, then cp_genericize_r won't then walk into those trees later on and
could avoid replacing there something important.  While for C, there is
walk_tree solely for the purposes of c_genericize_control* and nothing else.
To avoid testing it in every iteration you could have a hash_set<tree> *pset
temporary initialized based on c_dialect_cxx () to NULL or data and then just
use it in the loop.

>           if (TREE_CODE (t) != DEBUG_BEGIN_STMT
>           && (nondebug_stmts > 1 || TREE_SIDE_EFFECTS (tsi_stmt (i))))
>         clear_side_effects = false;

Reply via email to