]> granicus.if.org Git - clang/commitdiff
GNUNullExpr is a valid sentinel even though it isn't of pointer type.
authorAnders Carlsson <andersca@mac.com>
Tue, 24 Nov 2009 17:24:21 +0000 (17:24 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 24 Nov 2009 17:24:21 +0000 (17:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89778 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/attr-sentinel.cpp [new file with mode: 0644]

index 237472f56066252e4910c3720dad9cd3a947d3c5..b5dffdced6d2415add6a96af78dbcc9c4f978c5e 100644 (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;
   }
diff --git a/test/SemaCXX/attr-sentinel.cpp b/test/SemaCXX/attr-sentinel.cpp
new file mode 100644 (file)
index 0000000..0293a5d
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+void f(int, ...) __attribute__((sentinel));
+
+void g() {
+  f(1, 2, __null);
+}