Make sure to take the unqualified versions of the canonical types for 
type-checking pointer subtraction; if the canonical types aren't used,
the qualifiers won't always get stripped off correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55620 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ba13e7f..fe9a13e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1013,7 +1013,7 @@
       AssignConvertType ConvTy =
         CheckSingleAssignmentConstraints(ProtoArgType, Arg);
       TheCall->setArg(i, Arg);
-      
+
       if (DiagnoseAssignmentResult(ConvTy, Arg->getLocStart(), ProtoArgType,
                                    ArgType, Arg, "passing"))
         return true;
@@ -1700,8 +1700,9 @@
       }
       
       // Pointee types must be compatible.
-      if (!Context.typesAreCompatible(lpointee.getUnqualifiedType(), 
-                                      rpointee.getUnqualifiedType())) {
+      if (!Context.typesAreCompatible(
+              Context.getCanonicalType(lpointee).getUnqualifiedType(), 
+              Context.getCanonicalType(rpointee).getUnqualifiedType())) {
         Diag(loc, diag::err_typecheck_sub_ptr_compatible,
              lex->getType().getAsString(), rex->getType().getAsString(),
              lex->getSourceRange(), rex->getSourceRange());