From: Chris Lattner Date: Thu, 3 Apr 2008 05:07:25 +0000 (+0000) Subject: Fix a bug where we didn't check the RHS for null, we checked X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc896f58c714e765bedb8cf1390321128c011f17;p=clang Fix a bug where we didn't check the RHS for null, we checked the LHS for null twice. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49138 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9d75f4fdb5..d4a97c1f8c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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());