blob: a1d722b74294d74c632ca872999c88972ed8d1ab [file] [log] [blame]
Chris Lattnerca790922009-04-21 19:55:16 +00001// RUN: clang-cc -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
Daniel Dunbarff896662009-04-21 15:48:54 +00002
3@class I0;
Chris Lattnerca790922009-04-21 19:55:16 +00004
5// rdar://6811884
Chris Lattner1efaa952009-04-24 00:30:45 +00006int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}}
7
8// rdar://6821047
9void *g3(I0 *P) {
10 return &P[4]; // expected-error{{subscript of pointer to incomplete type 'I0'}}
11}
12
13
Daniel Dunbarff896662009-04-21 15:48:54 +000014
15@interface I0 {
Chris Lattner1efaa952009-04-24 00:30:45 +000016@public
Daniel Dunbarff896662009-04-21 15:48:54 +000017 char x[4];
18}
19
20@property int p0;
21@end
22
23// size == 4
Chris Lattner1efaa952009-04-24 00:30:45 +000024int g1[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
Chris Lattnerca790922009-04-21 19:55:16 +000025 == 4 ? 1 : -1];
Daniel Dunbarff896662009-04-21 15:48:54 +000026
27@implementation I0
28@synthesize p0 = _p0;
29@end
30
31// size == 4 (we do not include extended properties in the
32// sizeof).
Chris Lattner1efaa952009-04-24 00:30:45 +000033int g2[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
Chris Lattnerca790922009-04-21 19:55:16 +000034 == 4 ? 1 : -1];
Daniel Dunbarff896662009-04-21 15:48:54 +000035
36@interface I1
37@property int p0;
38@end
39
40@implementation I1
41@synthesize p0 = _p0;
42@end
43
Fariborz Jahanian0468fb92009-04-21 20:28:41 +000044typedef struct { @defs(I1) } I1_defs; // expected-error {{invalid application of @defs in non-fragile ABI}}
45
Daniel Dunbarff896662009-04-21 15:48:54 +000046// FIXME: This is currently broken due to the way the record layout we
47// create is tied to whether we have seen synthesized properties. Ugh.
48// int g3[ sizeof(I1) == 0 ? 1 : -1];
Chris Lattner1efaa952009-04-24 00:30:45 +000049
50// rdar://6821047
51int bar(I0 *P) {
52 return P[4].x[2]; // expected-error {{subscript requires size of interface 'I0', which is not constant in non-fragile ABI}}
53}
54
Fariborz Jahanianced1e282009-04-24 17:34:33 +000055
56@interface I @end
57
58@interface XCAttributeRunDirectNode
59{
60 @public
61 unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{invalid application of 'sizeof' to interface 'I' in non-fragile ABI}}
62 int i;
63}
64@end
65
66@implementation XCAttributeRunDirectNode
67
68- (unsigned long)gatherStats:(id )stats
69{
70 return attributeRuns[i];
71}
72@end
73