OSDN Git Service

PR c++/36254
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Jan 2009 21:14:51 +0000 (21:14 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Jan 2009 21:14:51 +0000 (21:14 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143281 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wreturn-type-5.C [new file with mode: 0644]

index b1542f0..7b0c39f 100644 (file)
@@ -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
index 144de3f..99738ea 100644 (file)
@@ -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)
index f8b0c49..c717262 100644 (file)
@@ -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
diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-5.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-5.C
new file mode 100644 (file)
index 0000000..8a19d64
--- /dev/null
@@ -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;
+}