diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-24 17:24:21 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-24 17:24:21 +0000 |
commit | 0b11a3ef71a966963d04da3fcbf15e35f00dab99 (patch) | |
tree | 7e76a5b182fa8c9d894e41341fa90c13df6777ff | |
parent | 03b67ea1a29c6d0dfcdbb0c18e73bd0850e9820b (diff) | |
download | bcm5719-llvm-0b11a3ef71a966963d04da3fcbf15e35f00dab99.tar.gz bcm5719-llvm-0b11a3ef71a966963d04da3fcbf15e35f00dab99.zip |
GNUNullExpr is a valid sentinel even though it isn't of pointer type.
llvm-svn: 89778
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/attr-sentinel.cpp | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 237472f5606..b5dffdced6d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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; } diff --git a/clang/test/SemaCXX/attr-sentinel.cpp b/clang/test/SemaCXX/attr-sentinel.cpp new file mode 100644 index 00000000000..0293a5dce00 --- /dev/null +++ b/clang/test/SemaCXX/attr-sentinel.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -fsyntax-only -verify %s +void f(int, ...) __attribute__((sentinel)); + +void g() { + f(1, 2, __null); +} |