Author: andersca
Date: Tue Nov 24 11:24:21 2009
New Revision: 89778

URL: http://llvm.org/viewvc/llvm-project?rev=89778&view=rev
Log:
GNUNullExpr is a valid sentinel even though it isn't of pointer type.

Added:
    cfe/trunk/test/SemaCXX/attr-sentinel.cpp
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=89778&r1=89777&r2=89778&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Nov 24 11:24:21 2009
@@ -152,9 +152,10 @@
     ++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;
   }

Added: cfe/trunk/test/SemaCXX/attr-sentinel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-sentinel.cpp?rev=89778&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/attr-sentinel.cpp (added)
+++ cfe/trunk/test/SemaCXX/attr-sentinel.cpp Tue Nov 24 11:24:21 2009
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+void f(int, ...) __attribute__((sentinel));
+
+void g() {
+  f(1, 2, __null);
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to