From e4d2bdd54c29656f2eba004d6db1e4942f2bfcd9 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 24 Nov 2009 17:24:21 +0000 Subject: [PATCH] GNUNullExpr is a valid sentinel even though it isn't of pointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89778 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 7 ++++--- test/SemaCXX/attr-sentinel.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/SemaCXX/attr-sentinel.cpp diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 237472f560..b5dffdced6 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/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(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/test/SemaCXX/attr-sentinel.cpp b/test/SemaCXX/attr-sentinel.cpp new file mode 100644 index 0000000000..0293a5dce0 --- /dev/null +++ b/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); +} -- 2.40.0