tree dtype = ntype = build_distinct_type_copy (ttype);
TYPE_ATTRIBUTES (ntype) = attribute;
+ /* If the target-dependent attributes make NTYPE different from
+ its canonical type, we will need to use structural equality
+ checks for this type.
+
+ We shouldn't get here for stripping attributes from a type;
+ the no-attribute type might not need structural comparison. But
+ we can if was discarded from type_hash_table. */
+ if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
+ || !comp_type_attributes (ntype, ttype))
+ SET_TYPE_STRUCTURAL_EQUALITY (ntype);
hashval_t hash = type_hash_canon_hash (ntype);
ntype = type_hash_canon (hash, ntype);
if (ntype != dtype)
/* This variant was already in the hash table, don't mess with
TYPE_CANONICAL. */;
- else if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
- || !comp_type_attributes (ntype, ttype))
- /* If the target-dependent attributes make NTYPE different from
- its canonical type, we will need to use structural equality
- checks for this type.
-
- We shouldn't get here for stripping attributes from a type;
- the no-attribute type might not need structural comparison. But
- we can if was discarded from type_hash_table. */
- SET_TYPE_STRUCTURAL_EQUALITY (ntype);
else if (TYPE_CANONICAL (ntype) == ntype)
TYPE_CANONICAL (ntype) = TYPE_CANONICAL (ttype);
TYPE_TYPELESS_STORAGE (main_type) = TYPE_TYPELESS_STORAGE (type);
layout_type (main_type);
+ /* Set TYPE_STRUCTURAL_EQUALITY_P early. */
+ if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type))
+ || TYPE_STRUCTURAL_EQUALITY_P (TYPE_DOMAIN (main_type)))
+ SET_TYPE_STRUCTURAL_EQUALITY (main_type);
+ else
+ TYPE_CANONICAL (main_type) = main_type;
+
/* Make sure we have the canonical MAIN_TYPE. */
hashval_t hashcode = type_hash_canon_hash (main_type);
main_type = type_hash_canon (hashcode, main_type);
/* Fix the canonical type. */
if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type))
|| TYPE_STRUCTURAL_EQUALITY_P (TYPE_DOMAIN (main_type)))
- SET_TYPE_STRUCTURAL_EQUALITY (main_type);
+ gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (main_type));
else if (TYPE_CANONICAL (TREE_TYPE (main_type)) != TREE_TYPE (main_type)
|| (TYPE_CANONICAL (TYPE_DOMAIN (main_type))
!= TYPE_DOMAIN (main_type)))
= build_array_type (TYPE_CANONICAL (TREE_TYPE (main_type)),
TYPE_CANONICAL (TYPE_DOMAIN (main_type)),
TYPE_TYPELESS_STORAGE (main_type));
- else
- TYPE_CANONICAL (main_type) = main_type;
if (quals == 0)
type = main_type;
hstate.add_int (TREE_CODE (type));
+ hstate.add_flag (TYPE_STRUCTURAL_EQUALITY_P (type));
+
if (TREE_TYPE (type))
hstate.add_object (TYPE_HASH (TREE_TYPE (type)));
|| TYPE_MODE (a->type) != TYPE_MODE (b->type)))
return false;
+ if (TYPE_STRUCTURAL_EQUALITY_P (a->type)
+ != TYPE_STRUCTURAL_EQUALITY_P (b->type))
+ return false;
+
switch (TREE_CODE (a->type))
{
case VOID_TYPE:
TYPE_DOMAIN (t) = index_type;
TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type);
TYPE_TYPELESS_STORAGE (t) = typeless_storage;
+
+ /* Set TYPE_STRUCTURAL_EQUALITY_P. */
+ if (set_canonical
+ && (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
+ || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
+ || in_lto_p))
+ SET_TYPE_STRUCTURAL_EQUALITY (t);
+
layout_type (t);
if (shared)
if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
|| (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
|| in_lto_p)
- SET_TYPE_STRUCTURAL_EQUALITY (t);
+ gcc_unreachable ();
else if (TYPE_CANONICAL (elt_type) != elt_type
|| (index_type && TYPE_CANONICAL (index_type) != index_type))
TYPE_CANONICAL (t)
TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
}
- /* If we already have such a type, use the old one. */
- hashval_t hash = type_hash_canon_hash (t);
- tree probe_type = t;
- t = type_hash_canon (hash, t);
- if (t != probe_type)
- return t;
-
/* Set up the canonical type. */
any_structural_p = TYPE_STRUCTURAL_EQUALITY_P (value_type);
any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
canon_argtypes = maybe_canonicalize_argtypes (arg_types,
&any_structural_p,
&any_noncanonical_p);
+ /* Set TYPE_STRUCTURAL_EQUALITY_P early. */
if (any_structural_p)
SET_TYPE_STRUCTURAL_EQUALITY (t);
+
+ /* If we already have such a type, use the old one. */
+ hashval_t hash = type_hash_canon_hash (t);
+ tree probe_type = t;
+ t = type_hash_canon (hash, t);
+ if (t != probe_type)
+ return t;
+
+ if (any_structural_p)
+ gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
else if (any_noncanonical_p)
TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
canon_argtypes);
argtypes = tree_cons (NULL_TREE, ptype, argtypes);
TYPE_ARG_TYPES (t) = argtypes;
- /* If we already have such a type, use the old one. */
- hashval_t hash = type_hash_canon_hash (t);
- tree probe_type = t;
- t = type_hash_canon (hash, t);
- if (t != probe_type)
- return t;
-
/* Set up the canonical type. */
any_structural_p
= (TYPE_STRUCTURAL_EQUALITY_P (basetype)
canon_argtypes = maybe_canonicalize_argtypes (TREE_CHAIN (argtypes),
&any_structural_p,
&any_noncanonical_p);
+
+ /* Set TYPE_STRUCTURAL_EQUALITY_P early. */
if (any_structural_p)
SET_TYPE_STRUCTURAL_EQUALITY (t);
+
+ /* If we already have such a type, use the old one. */
+ hashval_t hash = type_hash_canon_hash (t);
+ tree probe_type = t;
+ t = type_hash_canon (hash, t);
+ if (t != probe_type)
+ return t;
+
+ if (any_structural_p)
+ gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
else if (any_noncanonical_p)
TYPE_CANONICAL (t)
= build_method_type_directly (TYPE_CANONICAL (basetype),
TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
TREE_TYPE (t) = type;
+ if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
+ || TYPE_STRUCTURAL_EQUALITY_P (type))
+ SET_TYPE_STRUCTURAL_EQUALITY (t);
/* If we already have such a type, use the old one. */
hashval_t hash = type_hash_canon_hash (t);
{
if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
|| TYPE_STRUCTURAL_EQUALITY_P (type))
- SET_TYPE_STRUCTURAL_EQUALITY (t);
+ gcc_unreachable ();
else if (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)) != basetype
|| TYPE_CANONICAL (type) != type)
TYPE_CANONICAL (t)
tree probe = make_node (COMPLEX_TYPE);
TREE_TYPE (probe) = TYPE_MAIN_VARIANT (component_type);
+ if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (probe)))
+ SET_TYPE_STRUCTURAL_EQUALITY (probe);
/* If we already have such a type, use the old one. */
hashval_t hash = type_hash_canon_hash (probe);
out the type. We need to check the canonicalization and
maybe set the name. */
gcc_checking_assert (COMPLETE_TYPE_P (t)
- && !TYPE_NAME (t)
- && TYPE_CANONICAL (t) == t);
+ && !TYPE_NAME (t));
if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)))
- SET_TYPE_STRUCTURAL_EQUALITY (t);
+ ;
else if (TYPE_CANONICAL (TREE_TYPE (t)) != TREE_TYPE (t))
TYPE_CANONICAL (t)
= build_complex_type (TYPE_CANONICAL (TREE_TYPE (t)), named);