This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: PATCH to gimple_canonical_types_compatible_p for middle-end/66214
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 26 Nov 2015 10:34:44 +0100
- Subject: Re: RFA: PATCH to gimple_canonical_types_compatible_p for middle-end/66214
- Authentication-results: sourceware.org; auth=none
- References: <5655DA06 dot 4000506 at redhat dot com> <20151125191010 dot GA5371 at kam dot mff dot cuni dot cz> <56563234 dot 8040404 at redhat dot com> <20151125221451 dot GE20593 at kam dot mff dot cuni dot cz> <20151126063257 dot GA59662 at kam dot mff dot cuni dot cz>
On Thu, Nov 26, 2015 at 7:32 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> what aout this?
>
> Index: tree.c
> ===================================================================
> --- tree.c (revision 230924)
> +++ tree.c (working copy)
> @@ -13424,6 +13424,12 @@ gimple_canonical_types_compatible_p (con
> {
> tree f1, f2;
>
> + /* Don't try to compare variants of an incomplete type, before
> + TYPE_FIELDS has been copied around. */
> + if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2))
> + return true;
> +
As said, you shouldn't call this function on variants. It wasn't
designed for that. Please do the above
check where necessary in the caller (the verifier).
Overloading this for verification and canonical type compute now bites back...
RIchard.
> if (TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
> return false;
>
> @@ -13710,28 +13716,35 @@ verify_type (const_tree t)
> }
> }
> else if (RECORD_OR_UNION_TYPE_P (t))
> - for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
> - {
> - /* TODO: verify properties of decls. */
> - if (TREE_CODE (fld) == FIELD_DECL)
> - ;
> - else if (TREE_CODE (fld) == TYPE_DECL)
> - ;
> - else if (TREE_CODE (fld) == CONST_DECL)
> - ;
> - else if (TREE_CODE (fld) == VAR_DECL)
> - ;
> - else if (TREE_CODE (fld) == TEMPLATE_DECL)
> - ;
> - else if (TREE_CODE (fld) == USING_DECL)
> - ;
> - else
> - {
> - error ("Wrong tree in TYPE_FIELDS list");
> - debug_tree (fld);
> - error_found = true;
> - }
> - }
> + {
> + if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p)
> + {
> + error ("TYPE_FIELDS defined in incomplete type");
> + error_found = true;
> + }
> + for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
> + {
> + /* TODO: verify properties of decls. */
> + if (TREE_CODE (fld) == FIELD_DECL)
> + ;
> + else if (TREE_CODE (fld) == TYPE_DECL)
> + ;
> + else if (TREE_CODE (fld) == CONST_DECL)
> + ;
> + else if (TREE_CODE (fld) == VAR_DECL)
> + ;
> + else if (TREE_CODE (fld) == TEMPLATE_DECL)
> + ;
> + else if (TREE_CODE (fld) == USING_DECL)
> + ;
> + else
> + {
> + error ("Wrong tree in TYPE_FIELDS list");
> + debug_tree (fld);
> + error_found = true;
> + }
> + }
> + }
> else if (TREE_CODE (t) == INTEGER_TYPE
> || TREE_CODE (t) == BOOLEAN_TYPE
> || TREE_CODE (t) == OFFSET_TYPE