]> granicus.if.org Git - clang/commitdiff
Consider obective-c pointer arguments as valid sentinel args
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 14 Jul 2010 16:37:51 +0000 (16:37 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 14 Jul 2010 16:37:51 +0000 (16:37 +0000)
as well. Fixes radar 7975788.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjC/method-sentinel-attr.m

index cb3518ae83c024cf26a7ed6f2f0dc4473615ef39..c06943f6718edbd17b9c7088472a132e84d3e585 100644 (file)
@@ -164,7 +164,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
   if (!sentinelExpr) return;
   if (sentinelExpr->isTypeDependent()) return;
   if (sentinelExpr->isValueDependent()) return;
-  if (sentinelExpr->getType()->isPointerType() &&
+  if (sentinelExpr->getType()->isAnyPointerType() &&
       sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context,
                                             Expr::NPC_ValueDependentIsNull))
     return;
index 08358cc9154ad3b0804efe9965052af9393e785c..6ec362f6f72829df9b6ef27bb15d5e60c14470d6 100644 (file)
 - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1)));
 - (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3)));  // expected-error {{attribute requires 0, 1 or 2 argument(s)}}
 - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
+
+// rdar:// 7975788
+- (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo14 : (id)firstObj :  (Class)secondObj, ... __attribute__((sentinel(0,1)));
+- (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1)));
 @end
 
 int main ()
@@ -33,5 +39,11 @@ int main ()
   [p foo7:1, NULL]; // ok
 
   [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}}
+
+  // rdar:// 7975788
+  [ p foo13 : NULL]; 
+  [ p foo14 : 0 : NULL]; 
+  [ p foo16 : NULL]; 
+  [ p foo15 : NULL];
 }