1// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s 2 3@class I0; // expected-note 2{{forward declaration of class here}} 4 5// rdar://6811884 6int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}} 7 8// rdar://6821047 9void *g3(I0 *P) { 10 P = P+5; // expected-error {{arithmetic on a pointer to an incomplete type 'I0'}} 11 12 return &P[4]; // expected-error{{expected method to read array element not found on object of type 'I0 *'}} 13} 14 15 16 17@interface I0 { 18@public 19 char x[4]; 20} 21 22@property int p0; 23@end 24 25// size == 4 26int g1[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} 27 == 4 ? 1 : -1]; 28 29@implementation I0 30@synthesize p0 = _p0; 31@end 32 33// size == 4 (we do not include extended properties in the 34// sizeof). 35int g2[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} 36 == 4 ? 1 : -1]; 37 38@interface I1 39@property int p0; 40@end 41 42@implementation I1 43@synthesize p0 = _p0; 44@end 45 46typedef struct { @defs(I1); } I1_defs; // expected-error {{use of @defs is not supported on this architecture and platform}} 47 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]; 51 52// rdar://6821047 53int 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 *'}} 59} 60 61 62@interface I @end 63 64@interface XCAttributeRunDirectNode 65{ 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; 69} 70@end 71 72@implementation XCAttributeRunDirectNode 73 74- (unsigned long)gatherStats:(id )stats 75{ 76 return attributeRuns[i]; 77} 78@end 79 80 81@interface Foo @end 82 83int foo() 84{ 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}} 90} 91