From: Richard Guenther Date: Thu, 11 Oct 2007 08:58:28 +0000 (+0000) Subject: re PR middle-end/33724 (Type checking error with address-of and ref-all pointer type) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=20dcff2aec49d4274cf4564186ca11b78c01f4de;p=gcc.git re PR middle-end/33724 (Type checking error with address-of and ref-all pointer type) 2007-10-11 Richard Guenther 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d1c15a827d..e737cb70229 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-10-11 Richard Guenther + + 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 PR c/33726 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 49f071bc6ae..efb4ca4f8ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-10-11 Richard Guenther + + PR middle-end/33724 + * gcc.dg/pr33724.c: New testcase. + 2007-10-11 Richard Guenther PR c/33726 diff --git a/gcc/testsuite/gcc.dg/pr33724.c b/gcc/testsuite/gcc.dg/pr33724.c new file mode 100644 index 00000000000..7e8eb5ddd07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr33724.c @@ -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); +} + diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index dd817adcbba..05c69b8ae02 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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));