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 d716917..ce75122 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1801,16 +1801,16 @@
 /// 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