annotate clang/test/SemaObjC/method-sentinel-attr.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 #define NULL (void*)0
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 #define ATTR __attribute__ ((__sentinel__))
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 @interface INTF
anatofuz
parents:
diff changeset
8 - (void) foo1 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
anatofuz
parents:
diff changeset
9 - (void) foo3 : (int)x __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic functions}}
anatofuz
parents:
diff changeset
10 - (void) foo5 : (int)x, ... __attribute__ ((__sentinel__(1))); // expected-note {{method has been explicitly marked sentinel here}}
anatofuz
parents:
diff changeset
11 - (void) foo6 : (int)x, ... __attribute__ ((__sentinel__(5))); // expected-note {{method has been explicitly marked sentinel here}}
anatofuz
parents:
diff changeset
12 - (void) foo7 : (int)x, ... __attribute__ ((__sentinel__(0))); // expected-note {{method has been explicitly marked sentinel here}}
anatofuz
parents:
diff changeset
13 - (void) foo8 : (int)x, ... __attribute__ ((__sentinel__("a"))); // expected-error {{'__sentinel__' attribute requires parameter 1 to be an integer constant}}
anatofuz
parents:
diff changeset
14 - (void) foo9 : (int)x, ... __attribute__ ((__sentinel__(-1))); // expected-error {{'sentinel' parameter 1 less than zero}}
anatofuz
parents:
diff changeset
15 - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1)));
anatofuz
parents:
diff changeset
16 - (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3))); // expected-error {{'__sentinel__' attribute takes no more than 2 arguments}}
anatofuz
parents:
diff changeset
17 - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 // rdar://7975788
anatofuz
parents:
diff changeset
20 - (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1)));
anatofuz
parents:
diff changeset
21 - (id) foo14 : (id)firstObj : (Class)secondObj, ... __attribute__((sentinel(0,1)));
anatofuz
parents:
diff changeset
22 - (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1)));
anatofuz
parents:
diff changeset
23 - (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1)));
anatofuz
parents:
diff changeset
24 @end
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 int main ()
anatofuz
parents:
diff changeset
27 {
anatofuz
parents:
diff changeset
28 INTF *p;
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 [p foo1:1, NULL]; // OK
anatofuz
parents:
diff changeset
31 [p foo1:1, 0]; // expected-warning {{missing sentinel in method dispatch}}
anatofuz
parents:
diff changeset
32 [p foo5:1, NULL, 2]; // OK
anatofuz
parents:
diff changeset
33 [p foo5:1, 2, NULL, 1]; // OK
anatofuz
parents:
diff changeset
34 [p foo5:1, NULL, 2, 1]; // expected-warning {{missing sentinel in method dispatch}}
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 [p foo6:1,2,3,4,5,6,7]; // expected-warning {{missing sentinel in method dispatch}}
anatofuz
parents:
diff changeset
37 [p foo6:1,NULL,3,4,5,6,7]; // OK
anatofuz
parents:
diff changeset
38 [p foo7:1]; // expected-warning {{not enough variable arguments in 'foo7:' declaration to fit a sentinel}}
anatofuz
parents:
diff changeset
39 [p foo7:1, NULL]; // ok
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}}
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 // rdar://7975788
anatofuz
parents:
diff changeset
44 [ p foo13 : NULL];
anatofuz
parents:
diff changeset
45 [ p foo14 : 0 : NULL];
anatofuz
parents:
diff changeset
46 [ p foo16 : NULL];
anatofuz
parents:
diff changeset
47 [ p foo15 : NULL];
anatofuz
parents:
diff changeset
48 }
anatofuz
parents:
diff changeset
49