[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaObjC / sizeof-interface.m
blobdb765b79b4d8ade8d5252e774e940c983cf32754
1 // RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
3 @class I0; // expected-note 2{{forward declaration of class here}}
5 // rdar://6811884
6 int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}}
8 // rdar://6821047
9 void *g3(I0 *P) {
10   P = P+5;        // expected-error {{arithmetic on a pointer to an incomplete type 'I0'}}
12   return &P[4];   // expected-error{{expected method to read array element not found on object of type 'I0 *'}}
17 @interface I0 {
18 @public
19   char x[4];
22 @property int p0;
23 @end
25 // size == 4
26 int g1[ sizeof(I0)     // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}}
27        == 4 ? 1 : -1];
29 @implementation I0
30 @synthesize p0 = _p0;
31 @end
33 // size == 4 (we do not include extended properties in the
34 // sizeof).
35 int g2[ sizeof(I0)   // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}}
36        == 4 ? 1 : -1];
38 @interface I1
39 @property int p0;
40 @end
42 @implementation I1
43 @synthesize p0 = _p0;
44 @end
46 typedef struct { @defs(I1); } I1_defs; // expected-error {{use of @defs is not supported on this architecture and platform}}
48 // FIXME: This is currently broken due to the way the record layout we
49 // create is tied to whether we have seen synthesized properties. Ugh.
50 // int g3[ sizeof(I1) == 0 ? 1 : -1];
52 // rdar://6821047
53 int bar(I0 *P) {
54   P = P+5;  // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}}
55   P = 5+P;  // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}}
56   P = P-5;  // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}}
57   
58   return P[4].x[2];  // expected-error {{expected method to read array element not found on object of type 'I0 *'}}
62 @interface I @end
64 @interface XCAttributeRunDirectNode
66     @public
67     unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{application of 'sizeof' to interface 'I' is not supported on this architecture and platform}}
68     int i;
70 @end
72 @implementation XCAttributeRunDirectNode
74 - (unsigned long)gatherStats:(id )stats
76         return attributeRuns[i];
78 @end
81 @interface Foo @end
83 int foo()
85   Foo *f;
86   
87   // Both of these crash clang nicely
88   ++f;  // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}}
89   --f;  // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}}