return c_common_type (t1, t2);
}
+
+
+/* Helper function for comptypes. For two compatible types, return 1
+ if they pass consistency checks. In particular we test that
+ TYPE_CANONICAL is set correctly, i.e. the two types can alias. */
+
+static bool
+comptypes_verify (tree type1, tree type2)
+{
+ if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
+ && !TYPE_STRUCTURAL_EQUALITY_P (type1)
+ && !TYPE_STRUCTURAL_EQUALITY_P (type2))
+ {
+ /* FIXME: check other types. */
+ if (RECORD_OR_UNION_TYPE_P (type1)
+ || TREE_CODE (type1) == ENUMERAL_TYPE
+ || TREE_CODE (type2) == ENUMERAL_TYPE)
+ return false;
+ }
+ return true;
+}
+
struct comptypes_data {
bool enum_and_int_p;
bool different_types_p;
struct comptypes_data data = { };
bool ret = comptypes_internal (type1, type2, &data);
+ gcc_checking_assert (!ret || comptypes_verify (type1, type2));
+
return ret ? (data.warning_needed ? 2 : 1) : 0;
}
struct comptypes_data data = { };
bool ret = comptypes_internal (type1, type2, &data);
+ gcc_checking_assert (!ret || comptypes_verify (type1, type2));
+
if (data.different_types_p)
return false;
bool ret = comptypes_internal (type1, type2, &data);
*enum_and_int_p = data.enum_and_int_p;
+ gcc_checking_assert (!ret || comptypes_verify (type1, type2));
+
return ret ? (data.warning_needed ? 2 : 1) : 0;
}
bool ret = comptypes_internal (type1, type2, &data);
*different_types_p = data.different_types_p;
+ gcc_checking_assert (!ret || comptypes_verify (type1, type2));
+
return ret ? (data.warning_needed ? 2 : 1) : 0;
}
data.equiv = true;
bool ret = comptypes_internal (type1, type2, &data);
+ /* check that different equivance classes are assigned only
+ to types that are not compatible. */
+ gcc_checking_assert (ret || !comptypes (type1, type2));
+
return ret;
}
if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
return false;
- if (data->equiv && (C_TYPE_VARIABLE_SIZE (t1) || C_TYPE_VARIABLE_SIZE (t2)))
- return false;
-
for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
s1 && s2;
s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))