diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-03 05:07:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-03 05:07:25 +0000 |
commit | bc896f58c714e765bedb8cf1390321128c011f17 (patch) | |
tree | 71087b011db7803fae9f6b171b55ecb1c754ab38 | |
parent | 988ee6ef540d1203cf4aa52971f3c135c796bdf7 (diff) |
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
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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()); |