summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-03 05:07:25 +0000
committerChris Lattner <sabre@nondot.org>2008-04-03 05:07:25 +0000
commit3a0702e631c15af25ac9d3a4c915b3aa1ce7553f (patch)
treefa6643f7ac4daac6064bfb1f14d80a9e80068b70 /clang/lib/Sema
parentefdc7685d4b28e1a94d7b8dc39f1da5d361b99c8 (diff)
downloadbcm5719-llvm-3a0702e631c15af25ac9d3a4c915b3aa1ce7553f.tar.gz
bcm5719-llvm-3a0702e631c15af25ac9d3a4c915b3aa1ce7553f.zip
Fix a bug where we didn't check the RHS for null, we checked
the LHS for null twice. llvm-svn: 49138
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9d75f4fdb58..d4a97c1f8c9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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());
OpenPOWER on IntegriCloud