Commit f74d9c8f by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/36254 (wrong "control reaches end of non-void function" warning with IF_STMT)

	PR c++/36254
	* cp-gimplify.c (genericize_if_stmt): Renamed from ...
	(gimplify_if_stmt): ... this.
	(cp_gimplify_expr): Don't handle IF_STMT here.
	(cp_genericize_r): Call genericize_if_stmt for IF_STMT.

	* g++.dg/warn/Wreturn-type-5.C: New test.

From-SVN: r143281
parent 79ee9e8b
2009-01-11 Jakub Jelinek <jakub@redhat.com>
PR c++/36254
* cp-gimplify.c (genericize_if_stmt): Renamed from ...
(gimplify_if_stmt): ... this.
(cp_gimplify_expr): Don't handle IF_STMT here.
(cp_genericize_r): Call genericize_if_stmt for IF_STMT.
2009-01-10 Andrew Pinski <pinskia@gmail.com> 2009-01-10 Andrew Pinski <pinskia@gmail.com>
PR c++/38648 PR c++/38648
......
/* C++-specific tree lowering bits; see also c-gimplify.c and tree-gimple.c. /* C++-specific tree lowering bits; see also c-gimplify.c and tree-gimple.c.
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@redhat.com> Contributed by Jason Merrill <jason@redhat.com>
...@@ -158,7 +158,7 @@ genericize_eh_spec_block (tree *stmt_p) ...@@ -158,7 +158,7 @@ genericize_eh_spec_block (tree *stmt_p)
/* Genericize an IF_STMT by turning it into a COND_EXPR. */ /* Genericize an IF_STMT by turning it into a COND_EXPR. */
static void static void
gimplify_if_stmt (tree *stmt_p) genericize_if_stmt (tree *stmt_p)
{ {
tree stmt, cond, then_, else_; tree stmt, cond, then_, else_;
location_t locus = EXPR_LOCATION (*stmt_p); location_t locus = EXPR_LOCATION (*stmt_p);
...@@ -611,11 +611,6 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) ...@@ -611,11 +611,6 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
ret = GS_ALL_DONE; ret = GS_ALL_DONE;
break; break;
case IF_STMT:
gimplify_if_stmt (expr_p);
ret = GS_OK;
break;
case FOR_STMT: case FOR_STMT:
gimplify_for_stmt (expr_p, pre_p); gimplify_for_stmt (expr_p, pre_p);
ret = GS_OK; ret = GS_OK;
...@@ -803,6 +798,13 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) ...@@ -803,6 +798,13 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
CLEANUP_BODY (stmt), CLEANUP_BODY (stmt),
CLEANUP_EXPR (stmt)); CLEANUP_EXPR (stmt));
else if (TREE_CODE (stmt) == IF_STMT)
{
genericize_if_stmt (stmt_p);
/* *stmt_p has changed, tail recurse to handle it again. */
return cp_genericize_r (stmt_p, walk_subtrees, data);
}
/* COND_EXPR might have incompatible types in branches if one or both /* COND_EXPR might have incompatible types in branches if one or both
arms are bitfields. Fix it up now. */ arms are bitfields. Fix it up now. */
else if (TREE_CODE (stmt) == COND_EXPR) else if (TREE_CODE (stmt) == COND_EXPR)
......
2009-01-11 Jakub Jelinek <jakub@redhat.com>
PR c++/36254
* g++.dg/warn/Wreturn-type-5.C: New test.
2009-01-11 Matthias Klose <doko@ubuntu.com> 2009-01-11 Matthias Klose <doko@ubuntu.com>
PR middle-end/38616 PR middle-end/38616
......
// PR c++/36254
// { dg-do compile }
// { dg-options "-Wreturn-type" }
int i, j, k;
struct X { X (); ~X (); };
bool
foo ()
{
X x;
if (i && j)
{
if (k)
return true;
else
return false;
}
else
return false;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment