This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Genericize IF_STMT already during genericization, before gimplification (PR c++/36254)
On Thu, Jan 08, 2009 at 11:35:50PM +0100, Richard Guenther wrote:
> On Thu, Jan 8, 2009 at 11:30 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > shortcut_cond_expr uses block_may_fallthru to determine whether
> > a jump around else is needed or not. But this happens during
> > gimplification, before then and else are gimplified, and block_may_fallthru,
> > being a middle-end function, doesn't understand FE specific trees.
> > For if this can be fixed simply by genericizing IF_STMT into COND_EXPR
> > already during cp_genericize, before gimplification - there is nothing
> > in IF_STMT genericization that needs to be deferred till gimplification.
>
> Isn't this true for all frontend specific trees? That is, FOR_STMT isn't proper
Sure.
> GENERIC either - and don't we want to feed the gimplifier with GENERIC only?
I don't think we ever said that gimplifier will see GENERIC only, otherwise
gimplify_expr langhook would be useless. Even for C the gimplifier sees
some FE specific trees.
We certainly could add a stmt_may_fallthru langhook and handle IF_STMT in
it, but this seemed easier to me.
Handling FOR_STMT/DO_STMT/WHILE_STMT would be much harder, we'd need to look
for CONTINUE_STMT/BREAK_STMTs in it, perhaps even see if they are reachable
etc. The -Wreturn-type warning, at least as long as it warns so early,
is never going to be without false positives. We'd need some quick useless stmt
removal pass before warning...
int i, j, k;
struct X { X (); ~X (); };
bool
f2 ()
{
X x;
if (i && j)
do
return true;
while (1);
else
return false;
}
bool
f3 ()
{
X x;
if (i && j)
while (1)
return true;
else
return false;
}
are examples of false positives, while e.g. for while (1) { if (k) break; ... return true; }
we don't want to warn. My patch just made an easy change which cures one,
perhaps common, false positive, it doesn't have ambitions to kill all false
positives.
Jakub