OSDN Git Service

2007-10-04 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Oct 2007 14:35:32 +0000 (14:35 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Oct 2007 14:35:32 +0000 (14:35 +0000)
PR middle-end/33641
* tree-cfg.c (verify_gimple_expr): Operand one of POINTER_PLUS_EXPR
does not need to be of INTEGER_TYPE.
(verify_gimple_2): New function split out from ...
(verify_gimple_1): ... here.  ICE if there was an error during
verification.

* gcc.c-torture/compile/pr33641.c: New testcase.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr33641.c [new file with mode: 0644]
gcc/tree-cfg.c

index 455ad65..eef16c5 100644 (file)
@@ -1,3 +1,12 @@
+2007-10-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33641
+       * tree-cfg.c (verify_gimple_expr): Operand one of POINTER_PLUS_EXPR
+       does not need to be of INTEGER_TYPE.
+       (verify_gimple_2): New function split out from ...
+       (verify_gimple_1): ... here.  ICE if there was an error during
+       verification.
+
 2007-10-04  Michael Matz  <matz@suse.de>
 
        PR rtl-optimization/33653
index 38e86f2..5f1e3d7 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33641
+       * gcc.c-torture/compile/pr33641.c: New testcase.
+
 2007-10-04  Michael Matz  <matz@suse.de>
 
        PR rtl-optimization/33653
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr33641.c b/gcc/testsuite/gcc.c-torture/compile/pr33641.c
new file mode 100644 (file)
index 0000000..112f703
--- /dev/null
@@ -0,0 +1,12 @@
+/* This failed with type checking enabled.  */
+
+typedef enum { one, two } exp;
+extern exp pe;
+extern char pt[256];
+void psd (void (*f) (void *), void *p);
+static void rle (void *e) { }
+void
+foo (void)
+{
+  psd ((void (*)(void *)) (rle), (void *) (pt + pe));
+}
index 320bc8e..ad31924 100644 (file)
@@ -3724,7 +3724,6 @@ verify_gimple_expr (tree expr)
            return true;
          }
        if (!POINTER_TYPE_P (TREE_TYPE (op0))
-           || TREE_CODE (TREE_TYPE (op1)) != INTEGER_TYPE
            || !useless_type_conversion_p (type, TREE_TYPE (op0))
            || !useless_type_conversion_p (sizetype, TREE_TYPE (op1)))
          {
@@ -4023,12 +4022,14 @@ verify_gimple_stmt (tree stmt)
     }
 }
 
-/* Verify the GIMPLE statements inside the statement list STMTS.  */
+/* Verify the GIMPLE statements inside the statement list STMTS.
+   Returns true if there were any errors.  */
 
-void
-verify_gimple_1 (tree stmts)
+static bool
+verify_gimple_2 (tree stmts)
 {
   tree_stmt_iterator tsi;
+  bool err = false;
 
   for (tsi = tsi_start (stmts); !tsi_end_p (tsi); tsi_next (&tsi))
     {
@@ -4037,28 +4038,44 @@ verify_gimple_1 (tree stmts)
       switch (TREE_CODE (stmt))
        {
        case BIND_EXPR:
-         verify_gimple_1 (BIND_EXPR_BODY (stmt));
+         err |= verify_gimple_2 (BIND_EXPR_BODY (stmt));
          break;
 
        case TRY_CATCH_EXPR:
        case TRY_FINALLY_EXPR:
-         verify_gimple_1 (TREE_OPERAND (stmt, 0));
-         verify_gimple_1 (TREE_OPERAND (stmt, 1));
+         err |= verify_gimple_2 (TREE_OPERAND (stmt, 0));
+         err |= verify_gimple_2 (TREE_OPERAND (stmt, 1));
          break;
 
        case CATCH_EXPR:
-         verify_gimple_1 (CATCH_BODY (stmt));
+         err |= verify_gimple_2 (CATCH_BODY (stmt));
          break;
 
        case EH_FILTER_EXPR:
-         verify_gimple_1 (EH_FILTER_FAILURE (stmt));
+         err |= verify_gimple_2 (EH_FILTER_FAILURE (stmt));
          break;
 
        default:
-         if (verify_gimple_stmt (stmt))
-           debug_generic_expr (stmt);
+         {
+           bool err2 = verify_gimple_stmt (stmt);
+           if (err2)
+             debug_generic_expr (stmt);
+           err |= err2;
+         }
        }
     }
+
+  return err;
+}
+
+
+/* Verify the GIMPLE statements inside the statement list STMTS.  */
+
+void
+verify_gimple_1 (tree stmts)
+{
+  if (verify_gimple_2 (stmts))
+    internal_error ("verify_gimple failed");
 }
 
 /* Verify the GIMPLE statements inside the current function.  */