]> granicus.if.org Git - clang/commitdiff
qualifier comparisons should be done on canonical types.
authorChris Lattner <sabre@nondot.org>
Thu, 3 Apr 2008 05:07:04 +0000 (05:07 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 3 Apr 2008 05:07:04 +0000 (05:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49137 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp

index d716917b9ce4e98a1f161adec46d5550b94cc204..ce75122b3d7bf80f43d31160a46ad8efbd33cab4 100644 (file)
@@ -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