Debian Codegraph @

clang/test/SemaObjC/method-attributes.m

raw
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -verify -fsyntax-only -Wno-objc-root-class %s
2
3 @class NSString;
4
5 @interface A
6 -t1 __attribute__((noreturn));
7 - (NSString *)stringByAppendingFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
8 -(void) m0 __attribute__((noreturn));
9 -(void) m1 __attribute__((unused));
10 -(void) m2 __attribute__((stdcall));
11 -(void) m3 __attribute__((optnone));
12 @end
13
14
15 @interface INTF
16 - (int) foo1: (int)arg1 __attribute__((deprecated));
17
18 - (int) foo: (int)arg1;
19
20 - (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable));
21 - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));
22 @end
23
24 @implementation INTF
25 - (int) foo: (int)arg1 __attribute__((deprecated)){
26 return 10;
27 }
28 - (int) foo1: (int)arg1 {
29 return 10;
30 }
31 - (int) foo2: (int)arg1 __attribute__((deprecated)) {
32 return 10;
33 }
34 - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self)) {return 0; }
35 - (void) dep __attribute__((deprecated)) { } // OK private methodn
36 @end
37
38 @interface Foo
39 - (void)doSomething1:(id)sender;
40 - (void)doSomething2:(id)sender;
41 @end
42
43 @implementation Foo
44 - (void)doSomething1:(id)sender{}
45 - (void)doSomething2:(id)sender{}
46 @end
47
48 @interface Bar : Foo
49 - (IBAction)doSomething1:(id)sender;
50 @end
51 @implementation Bar
52 - (IBAction)doSomething1:(id)sender {}
53 - (IBAction)doSomething2:(id)sender {}
54 - (IBAction)doSomething3:(id)sender {}
55 @end
56
57 @interface NSObject @end
58
59 @interface Test : NSObject
60 -(id)method __attribute__((deprecated));
61 -(id)method1;
62 -(id)method2 __attribute__((aligned(16)));
63 - (id) method3: (int)arg1 __attribute__((aligned(16))) __attribute__((deprecated)) __attribute__((unavailable));
64 - (id) method4: (int)arg1 __attribute__((aligned(16))) __attribute__((deprecated)) __attribute__((unavailable));
65 @end
66
67 @implementation Test
68 -(id)method __attribute__((aligned(16))) __attribute__((aligned(16))) __attribute__((deprecated)) {
69 return self;
70 }
71 -(id)method1 __attribute__((aligned(16))) {
72 return self;
73 }
74 -(id)method2 {
75 return self;
76 }
77 - (id) method3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) {
78 return self;
79 }
80 - (id) method4: (int)arg1 __attribute__((aligned(16))) __attribute__((deprecated)) __attribute__((unavailable)) {
81 return self;
82 }
83 @end
84
85 __attribute__((cdecl)) // expected-warning {{'cdecl' attribute only applies to functions and methods}}
86 @interface Complain
87 @end
88
89 @interface rdar15450637 : NSObject
90 @property int p __attribute__((section("__TEXT,foo")));
91
92 - (id) IMethod :(int) count, ... __attribute__((section("__TEXT,foo")));
93
94 + (void) CMethod : (id) Obj __attribute__((section("__TEXT,fee")));
95 @end
96
97 // Section type conflicts between methods/properties and global variables
98 const int global1 __attribute__((section("seg1,sec1"))) = 10; // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
99 int global2 __attribute__((section("seg2,sec2"))) = 10; // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
100
101 @interface section_conflicts : NSObject
102 @property int p1 __attribute__((section("seg1,sec1"))); // expected-error {{'p1' causes a section type conflict with 'global1'}}
103 @property int p2 __attribute__((section("seg2,sec2"))); // expected-error {{'p2' causes a section type conflict with 'global2'}}
104
105 - (void)imethod1 __attribute__((section("seg1,sec1"))); // expected-error {{'imethod1' causes a section type conflict with 'global1'}}
106 - (void)imethod2 __attribute__((section("seg2,sec2"))); // expected-error {{'imethod2' causes a section type conflict with 'global2'}}
107
108 + (void)cmethod1:(id)Obj __attribute__((section("seg1,sec1"))); // expected-error {{'cmethod1:' causes a section type conflict with 'global1'}}
109 + (void)cmethod2:(id)Obj __attribute__((section("seg2,sec2"))); // expected-error {{'cmethod2:' causes a section type conflict with 'global2'}}
110 @end