From 30d1fbc80352fc335c9febcd2492046044dfb04d Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Sun, 20 May 2007 19:46:53 +0000 Subject: [PATCH] Bug #: Submitted by: Reviewed by: Bozo bug in last checkin. Needed to move the check for null pointers up (and out of the pointer/pointer clause). llvm-svn: 39466 --- clang/AST/SemaExpr.cpp | 10 +++++----- clang/Sema/SemaExpr.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clang/AST/SemaExpr.cpp b/clang/AST/SemaExpr.cpp index 035bac279a4a..67aa839c1220 100644 --- a/clang/AST/SemaExpr.cpp +++ b/clang/AST/SemaExpr.cpp @@ -421,6 +421,11 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 return QualType(); } } + if (lhs->isPointerType() && RHS->isNullPointerConstant()) // C99 6.5.15p3 + return lhs; + if (rhs->isPointerType() && LHS->isNullPointerConstant()) + return rhs; + if (lhs->isPointerType() && rhs->isPointerType()) { // C99 6.5.15p3,6 QualType lhptee, rhptee; @@ -428,11 +433,6 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 lhptee = cast(lhs.getCanonicalType())->getPointeeType(); rhptee = cast(rhs.getCanonicalType())->getPointeeType(); - if (RHS->isNullPointerConstant()) // C99 6.5.15p3 - return lhs; - if (LHS->isNullPointerConstant()) - return rhs; - // ignore qualifiers on void (C99 6.5.15p3, clause 6) if (lhptee.getUnqualifiedType()->isVoidType() && (rhptee->isObjectType() || rhptee->isIncompleteType())) diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 035bac279a4a..67aa839c1220 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/Sema/SemaExpr.cpp @@ -421,6 +421,11 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 return QualType(); } } + if (lhs->isPointerType() && RHS->isNullPointerConstant()) // C99 6.5.15p3 + return lhs; + if (rhs->isPointerType() && LHS->isNullPointerConstant()) + return rhs; + if (lhs->isPointerType() && rhs->isPointerType()) { // C99 6.5.15p3,6 QualType lhptee, rhptee; @@ -428,11 +433,6 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 lhptee = cast(lhs.getCanonicalType())->getPointeeType(); rhptee = cast(rhs.getCanonicalType())->getPointeeType(); - if (RHS->isNullPointerConstant()) // C99 6.5.15p3 - return lhs; - if (LHS->isNullPointerConstant()) - return rhs; - // ignore qualifiers on void (C99 6.5.15p3, clause 6) if (lhptee.getUnqualifiedType()->isVoidType() && (rhptee->isObjectType() || rhptee->isIncompleteType()))