forked from OSchip/llvm-project
Expressions of type std::nullptr_t can be used as sentinels.
llvm-svn: 118276
This commit is contained in:
parent
6c25ca4f2b
commit
e981a8c231
|
@ -193,6 +193,10 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
|||
if (!sentinelExpr) return;
|
||||
if (sentinelExpr->isTypeDependent()) return;
|
||||
if (sentinelExpr->isValueDependent()) return;
|
||||
|
||||
// nullptr_t is always treated as null.
|
||||
if (sentinelExpr->getType()->isNullPtrType()) return;
|
||||
|
||||
if (sentinelExpr->getType()->isAnyPointerType() &&
|
||||
sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context,
|
||||
Expr::NPC_ValueDependentIsNull))
|
||||
|
|
|
@ -84,3 +84,12 @@ bool g(bool);
|
|||
// Test that we prefer g(void*) over g(bool).
|
||||
static_assert(is_same<decltype(g(nullptr)), void*>::value, "");
|
||||
}
|
||||
|
||||
namespace test2 {
|
||||
void f(int, ...) __attribute__((sentinel));
|
||||
|
||||
void g() {
|
||||
// nullptr can be used as the sentinel value.
|
||||
f(10, nullptr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue