checked. */
code = tree_code_for_canonical_type_merging (TREE_CODE (type));
hstate.add_int (code);
- hstate.add_int (TYPE_MODE (type));
+ if (!RECORD_OR_UNION_TYPE_P (type))
+ hstate.add_int (TYPE_MODE (type));
/* Incorporate common features of numerical types. */
if (INTEGRAL_TYPE_P (type)
|| TREE_CODE (t1) == NULLPTR_TYPE)
return true;
- /* Can't be the same type if they have different mode. */
- if (TYPE_MODE (t1) != TYPE_MODE (t2))
+ /* Can't be compatible types if they have different mode. Because of
+ flexible array members, we allow mismatching modes for structures or
+ unions. */
+ if (!RECORD_OR_UNION_TYPE_P (t1)
+ && TYPE_MODE (t1) != TYPE_MODE (t2))
return false;
/* Non-aggregate types can be handled cheaply. */
debug_tree (ct);
error_found = true;
}
-
if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
+ /* We allow a mismatch for structure or union because of
+ flexible array members. */
+ && !RECORD_OR_UNION_TYPE_P (t)
+ && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t))
&& TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
{
error ("%<TYPE_MODE%> of %<TYPE_CANONICAL%> is not compatible");