diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Type.cpp | 26 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 5 |
2 files changed, 4 insertions, 27 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index b30f8966b6..583cb5d57c 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -288,32 +288,6 @@ bool Type::isDerivedType() const { return false; } } - -/// \brief Tests whether the type behaves like a pointer type. -/// -/// This includes all of the obviously pointer types including block pointers, -/// member pointers, and ObjC Object pointers. It also includes function and -/// array types which behave as pointers due to decay. -/// -/// \returns True for types which act like pointer types. -bool Type::isPointerLikeType() const { - switch (CanonicalType->getTypeClass()) { - case Pointer: - case BlockPointer: - case MemberPointer: - case ConstantArray: - case IncompleteArray: - case VariableArray: - case DependentSizedArray: - case FunctionProto: - case FunctionNoProto: - case ObjCObjectPointer: - return true; - default: - return false; - } -} - bool Type::isClassType() const { if (const RecordType *RT = getAs<RecordType>()) return RT->getDecl()->isClass(); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 15751d078b..42ec82ac4a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -8963,7 +8963,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, QualType LeftType = lhs.get()->getType(); QualType RightType = rhs.get()->getType(); if (LeftNull != RightNull && - !LeftType->isPointerLikeType() && !RightType->isPointerLikeType()) { + !LeftType->isPointerLikeType() && + !LeftType->canDecayToPointerType() && + !RightType->isPointerLikeType() && + !RightType->canDecayToPointerType()) { Diag(OpLoc, diag::warn_null_in_arithmetic_operation) << (LeftNull ? lhs.get()->getSourceRange() : rhs.get()->getSourceRange()); |