Consider obective-c pointer arguments as valid sentinel args

as well. Fixes radar 7975788.

llvm-svn: 108333
This commit is contained in:
Fariborz Jahanian 2010-07-14 16:37:51 +00:00
parent 1aef53403f
commit c0b0ced477
2 changed files with 13 additions and 1 deletions

View File

@ -164,7 +164,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
if (!sentinelExpr) return; if (!sentinelExpr) return;
if (sentinelExpr->isTypeDependent()) return; if (sentinelExpr->isTypeDependent()) return;
if (sentinelExpr->isValueDependent()) return; if (sentinelExpr->isValueDependent()) return;
if (sentinelExpr->getType()->isPointerType() && if (sentinelExpr->getType()->isAnyPointerType() &&
sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context, sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context,
Expr::NPC_ValueDependentIsNull)) Expr::NPC_ValueDependentIsNull))
return; return;

View File

@ -15,6 +15,12 @@
- (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1))); - (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) 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}} - (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 @end
int main () int main ()
@ -33,5 +39,11 @@ int main ()
[p foo7:1, NULL]; // ok [p foo7:1, NULL]; // ok
[p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}} [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];
} }