GNUNullExpr is a valid sentinel even though it isn't of pointer type.

llvm-svn: 89778
This commit is contained in:
Anders Carlsson
2009-11-24 17:24:21 +00:00
parent 03b67ea1a2
commit 0b11a3ef71
2 changed files with 10 additions and 3 deletions

View File

@@ -152,9 +152,10 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
++sentinel;
}
Expr *sentinelExpr = Args[sentinel];
if (sentinelExpr && (!sentinelExpr->getType()->isPointerType() ||
!sentinelExpr->isNullPointerConstant(Context,
Expr::NPC_ValueDependentIsNull))) {
if (sentinelExpr && (!isa<GNUNullExpr>(sentinelExpr) &&
(!sentinelExpr->getType()->isPointerType() ||
!sentinelExpr->isNullPointerConstant(Context,
Expr::NPC_ValueDependentIsNull)))) {
Diag(Loc, diag::warn_missing_sentinel) << isMethod;
Diag(D->getLocation(), diag::note_sentinel_here) << isMethod;
}

View File

@@ -0,0 +1,6 @@
// RUN: clang-cc -fsyntax-only -verify %s
void f(int, ...) __attribute__((sentinel));
void g() {
f(1, 2, __null);
}