1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li#define NULL (void*)0 4*67e74705SXin Li 5*67e74705SXin Li#define ATTR __attribute__ ((__sentinel__)) 6*67e74705SXin Li 7*67e74705SXin Li@interface INTF 8*67e74705SXin Li- (void) foo1 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}} 9*67e74705SXin Li- (void) foo3 : (int)x __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic functions}} 10*67e74705SXin Li- (void) foo5 : (int)x, ... __attribute__ ((__sentinel__(1))); // expected-note {{method has been explicitly marked sentinel here}} 11*67e74705SXin Li- (void) foo6 : (int)x, ... __attribute__ ((__sentinel__(5))); // expected-note {{method has been explicitly marked sentinel here}} 12*67e74705SXin Li- (void) foo7 : (int)x, ... __attribute__ ((__sentinel__(0))); // expected-note {{method has been explicitly marked sentinel here}} 13*67e74705SXin Li- (void) foo8 : (int)x, ... __attribute__ ((__sentinel__("a"))); // expected-error {{'__sentinel__' attribute requires parameter 1 to be an integer constant}} 14*67e74705SXin Li- (void) foo9 : (int)x, ... __attribute__ ((__sentinel__(-1))); // expected-error {{'sentinel' parameter 1 less than zero}} 15*67e74705SXin Li- (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1))); 16*67e74705SXin Li- (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3))); // expected-error {{'__sentinel__' attribute takes no more than 2 arguments}} 17*67e74705SXin Li- (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}} 18*67e74705SXin Li 19*67e74705SXin Li// rdar://7975788 20*67e74705SXin Li- (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1))); 21*67e74705SXin Li- (id) foo14 : (id)firstObj : (Class)secondObj, ... __attribute__((sentinel(0,1))); 22*67e74705SXin Li- (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1))); 23*67e74705SXin Li- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1))); 24*67e74705SXin Li@end 25*67e74705SXin Li 26*67e74705SXin Liint main () 27*67e74705SXin Li{ 28*67e74705SXin Li INTF *p; 29*67e74705SXin Li 30*67e74705SXin Li [p foo1:1, NULL]; // OK 31*67e74705SXin Li [p foo1:1, 0]; // expected-warning {{missing sentinel in method dispatch}} 32*67e74705SXin Li [p foo5:1, NULL, 2]; // OK 33*67e74705SXin Li [p foo5:1, 2, NULL, 1]; // OK 34*67e74705SXin Li [p foo5:1, NULL, 2, 1]; // expected-warning {{missing sentinel in method dispatch}} 35*67e74705SXin Li 36*67e74705SXin Li [p foo6:1,2,3,4,5,6,7]; // expected-warning {{missing sentinel in method dispatch}} 37*67e74705SXin Li [p foo6:1,NULL,3,4,5,6,7]; // OK 38*67e74705SXin Li [p foo7:1]; // expected-warning {{not enough variable arguments in 'foo7:' declaration to fit a sentinel}} 39*67e74705SXin Li [p foo7:1, NULL]; // ok 40*67e74705SXin Li 41*67e74705SXin Li [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}} 42*67e74705SXin Li 43*67e74705SXin Li // rdar://7975788 44*67e74705SXin Li [ p foo13 : NULL]; 45*67e74705SXin Li [ p foo14 : 0 : NULL]; 46*67e74705SXin Li [ p foo16 : NULL]; 47*67e74705SXin Li [ p foo15 : NULL]; 48*67e74705SXin Li} 49*67e74705SXin Li 50