/// C99 6.2.7p1: Two types have compatible types if their types are the
/// same. See 6.7.[2,3,5] for additional rules.
bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
- if (lhs.getCVRQualifiers() != rhs.getCVRQualifiers() ||
- lhs.getAddressSpace() != rhs.getAddressSpace())
- return false;
-
QualType lcanon = lhs.getCanonicalType();
QualType rcanon = rhs.getCanonicalType();
-
+
// If two types are identical, they are are compatible
if (lcanon == rcanon)
return true;
+
+ if (lcanon.getCVRQualifiers() != rcanon.getCVRQualifiers() ||
+ lcanon.getAddressSpace() != rcanon.getAddressSpace())
+ return false;
// C++ [expr]: If an expression initially has the type "reference to T", the
// type is adjusted to "T" prior to any further analysis, the expression