зеркало из https://github.com/microsoft/clang.git
Implement comparisons between nullptr and Objective-C object
pointers. Fixes PR10052. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132397 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4e1ff2b6c9
Коммит
17e37c7959
|
@ -7536,7 +7536,7 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca
|
||||||
// Comparison of pointers with null pointer constants and equality
|
// Comparison of pointers with null pointer constants and equality
|
||||||
// comparisons of member pointers to null pointer constants.
|
// comparisons of member pointers to null pointer constants.
|
||||||
if (RHSIsNull &&
|
if (RHSIsNull &&
|
||||||
((lType->isPointerType() || lType->isNullPtrType()) ||
|
((lType->isAnyPointerType() || lType->isNullPtrType()) ||
|
||||||
(!isRelational && lType->isMemberPointerType()))) {
|
(!isRelational && lType->isMemberPointerType()))) {
|
||||||
rex = ImpCastExprToType(rex.take(), lType,
|
rex = ImpCastExprToType(rex.take(), lType,
|
||||||
lType->isMemberPointerType()
|
lType->isMemberPointerType()
|
||||||
|
@ -7545,7 +7545,7 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca
|
||||||
return ResultTy;
|
return ResultTy;
|
||||||
}
|
}
|
||||||
if (LHSIsNull &&
|
if (LHSIsNull &&
|
||||||
((rType->isPointerType() || rType->isNullPtrType()) ||
|
((rType->isAnyPointerType() || rType->isNullPtrType()) ||
|
||||||
(!isRelational && rType->isMemberPointerType()))) {
|
(!isRelational && rType->isMemberPointerType()))) {
|
||||||
lex = ImpCastExprToType(lex.take(), rType,
|
lex = ImpCastExprToType(lex.take(), rType,
|
||||||
rType->isMemberPointerType()
|
rType->isMemberPointerType()
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
|
||||||
|
|
||||||
|
@interface A
|
||||||
|
@end
|
||||||
|
|
||||||
|
void comparisons(A *a) {
|
||||||
|
(void)(a == nullptr);
|
||||||
|
(void)(nullptr == a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assignment(A *a) {
|
||||||
|
a = nullptr;
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче