mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-10 21:41:14 +08:00
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
This commit is contained in:
parent
79ee9e8be8
commit
f74d9c8f93
@ -1,3 +1,11 @@
|
||||
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>
|
||||
|
||||
PR c++/38648
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
Contributed by Jason Merrill <jason@redhat.com>
|
||||
|
||||
@ -158,7 +158,7 @@ genericize_eh_spec_block (tree *stmt_p)
|
||||
/* Genericize an IF_STMT by turning it into a COND_EXPR. */
|
||||
|
||||
static void
|
||||
gimplify_if_stmt (tree *stmt_p)
|
||||
genericize_if_stmt (tree *stmt_p)
|
||||
{
|
||||
tree stmt, cond, then_, else_;
|
||||
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)
|
||||
ret = GS_ALL_DONE;
|
||||
break;
|
||||
|
||||
case IF_STMT:
|
||||
gimplify_if_stmt (expr_p);
|
||||
ret = GS_OK;
|
||||
break;
|
||||
|
||||
case FOR_STMT:
|
||||
gimplify_for_stmt (expr_p, pre_p);
|
||||
ret = GS_OK;
|
||||
@ -803,6 +798,13 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
|
||||
CLEANUP_BODY (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
|
||||
arms are bitfields. Fix it up now. */
|
||||
else if (TREE_CODE (stmt) == COND_EXPR)
|
||||
|
@ -1,3 +1,8 @@
|
||||
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>
|
||||
|
||||
PR middle-end/38616
|
||||
|
21
gcc/testsuite/g++.dg/warn/Wreturn-type-5.C
Normal file
21
gcc/testsuite/g++.dg/warn/Wreturn-type-5.C
Normal file
@ -0,0 +1,21 @@
|
||||
// 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user