]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/33724 (Type checking error with address-of and ref-all pointer type)
authorRichard Guenther <rguenther@suse.de>
Thu, 11 Oct 2007 08:58:28 +0000 (08:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 11 Oct 2007 08:58:28 +0000 (08:58 +0000)
2007-10-11  Richard Guenther  <rguenther@suse.de>

PR middle-end/33724
* tree-cfg.c (one_pointer_to_useless_type_conversion_p): New function.
(verify_gimple_expr): Use it to verify pointer-to types for
ADDR_EXPRs.

* gcc.dg/pr33724.c: New testcase.

From-SVN: r129228

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr33724.c [new file with mode: 0644]
gcc/tree-cfg.c

index 0d1c15a827dc8602cf803f1886fa0e369a129084..e737cb70229ed052b56c05d8229a57bd337fc77e 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-11  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33724
+       * tree-cfg.c (one_pointer_to_useless_type_conversion_p): New function.
+       (verify_gimple_expr): Use it to verify pointer-to types for
+       ADDR_EXPRs.
+
 2007-10-11  Richard Guenther  <rguenther@suse.de>
 
        PR c/33726
index 49f071bc6ae0bdcdc283324349f1fa5e16e75a3e..efb4ca4f8ec6d8292cd47381c3382cc9b2128a24 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-11  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33724
+       * gcc.dg/pr33724.c: New testcase.
+
 2007-10-11  Richard Guenther  <rguenther@suse.de>
 
        PR c/33726
diff --git a/gcc/testsuite/gcc.dg/pr33724.c b/gcc/testsuite/gcc.dg/pr33724.c
new file mode 100644 (file)
index 0000000..7e8eb5d
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+/* We ICEd with type-checking enabled.  */
+
+struct xt_entry_target {
+  char name[1];
+};
+struct ipt_entry {
+  unsigned char elems[1];
+};
+void match_different(const unsigned char *);
+int dump_entry(struct xt_entry_target *t)
+{
+  return __builtin_strcmp (t->name, "");
+}
+void is_same(const struct ipt_entry *a)
+{
+  match_different(a->elems);
+}
+
index dd817adcbba088eb669822fa5f3c6d27874a6205..05c69b8ae02533827c8deb5f61ef595d12438b67 100644 (file)
@@ -3538,6 +3538,24 @@ verify_gimple_reference (tree expr)
   return verify_gimple_min_lval (expr);
 }
 
+/* Returns true if there is one pointer type in TYPE_POINTER_TO (SRC_OBJ)
+   list of pointer-to types that is trivially convertible to DEST.  */
+
+static bool
+one_pointer_to_useless_type_conversion_p (tree dest, tree src_obj)
+{
+  tree src;
+
+  if (!TYPE_POINTER_TO (src_obj))
+    return true;
+
+  for (src = TYPE_POINTER_TO (src_obj); src; src = TYPE_NEXT_PTR_TO (src))
+    if (useless_type_conversion_p (dest, src))
+      return true;
+
+  return false;
+}
+
 /* Verify the GIMPLE expression EXPR.  Returns true if there is an
    error, otherwise false.  */
 
@@ -3773,14 +3791,11 @@ verify_gimple_expr (tree expr)
            error ("invalid operand in unary expression");
            return true;
          }
-       if (TYPE_POINTER_TO (TREE_TYPE (op))
-           && !useless_type_conversion_p (type,
-                                          TYPE_POINTER_TO (TREE_TYPE (op)))
+       if (!one_pointer_to_useless_type_conversion_p (type, TREE_TYPE (op))
            /* FIXME: a longstanding wart, &a == &a[0].  */
            && (TREE_CODE (TREE_TYPE (op)) != ARRAY_TYPE
-               || (TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (op)))
-                   && !useless_type_conversion_p (type,
-                         TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (op)))))))
+               || !one_pointer_to_useless_type_conversion_p (type,
+                     TREE_TYPE (TREE_TYPE (op)))))
          {
            error ("type mismatch in address expression");
            debug_generic_stmt (TREE_TYPE (expr));