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