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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, cp/semantics.cc has for this simplify_loop_decl_cond
/* If *COND_P specifies a conditional with a declaration, transform the
   loop such that
            while (A x = 42) { }
            for (; A x = 42;) { }
   becomes
            while (true) { A x = 42; if (!x) break; }
            for (;;) { A x = 42; if (!x) break; }
   The statement list for BODY will be empty if the conditional did
   not declare anything.  */
But, if it does this transformation, this PR means we need to arrange for the
expression to be added to the body as well, but not in the C++ FE but during
the genericization, because the continue label needs to go before the
expression.
So perhaps let simplify_loop_decl should set some flag on FOR_STMT if it does
this transformation.
I think we need to get the destructors in the body right for that case though,
even when not using explicit {}s around the body.

Reply via email to