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()))