]> granicus.if.org Git - clang/commitdiff
Fix a bug where we didn't check the RHS for null, we checked
authorChris Lattner <sabre@nondot.org>
Thu, 3 Apr 2008 05:07:25 +0000 (05:07 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 3 Apr 2008 05:07:25 +0000 (05:07 +0000)
the LHS for null twice.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49138 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 9d75f4fdb58e9c48c147cb7c3352e88574151723..d4a97c1f8c9558b95096a0a712a48b6472199354 100644 (file)
@@ -1494,13 +1494,15 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
   // when handling null pointer constants. One day, we can consider making them
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
-    QualType lpointee = lType->getAsPointerType()->getPointeeType();
-    QualType rpointee = rType->getAsPointerType()->getPointeeType();
+    QualType LCanPointeeTy =
+      lType->getAsPointerType()->getPointeeType().getCanonicalType();
+    QualType RCanPointeeTy =
+      rType->getAsPointerType()->getPointeeType().getCanonicalType();
     
     if (!LHSIsNull && !RHSIsNull &&                       // C99 6.5.9p2
-        !lpointee->isVoidType() && !lpointee->isVoidType() &&
-        !Context.typesAreCompatible(lpointee.getUnqualifiedType(),
-                                    rpointee.getUnqualifiedType())) {
+        !LCanPointeeTy->isVoidType() && !RCanPointeeTy->isVoidType() &&
+        !Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
+                                    RCanPointeeTy.getUnqualifiedType())) {
       Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
            lType.getAsString(), rType.getAsString(),
            lex->getSourceRange(), rex->getSourceRange());