From: Chris Lattner Date: Thu, 3 Apr 2008 05:07:04 +0000 (+0000) Subject: qualifier comparisons should be done on canonical types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=988ee6ef540d1203cf4aa52971f3c135c796bdf7;p=clang qualifier comparisons should be done on canonical types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index d716917b9c..ce75122b3d 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1801,16 +1801,16 @@ bool ASTContext::arrayTypesAreCompatible(QualType lhs, QualType rhs) { /// 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