1*67e74705SXin Li// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s 2*67e74705SXin Li 3*67e74705SXin Li@class I0; // expected-note 2{{forward declaration of class here}} 4*67e74705SXin Li 5*67e74705SXin Li// rdar://6811884 6*67e74705SXin Liint g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}} 7*67e74705SXin Li 8*67e74705SXin Li// rdar://6821047 9*67e74705SXin Livoid *g3(I0 *P) { 10*67e74705SXin Li P = P+5; // expected-error {{arithmetic on a pointer to an incomplete type 'I0'}} 11*67e74705SXin Li 12*67e74705SXin Li return &P[4]; // expected-error{{expected method to read array element not found on object of type 'I0 *'}} 13*67e74705SXin Li} 14*67e74705SXin Li 15*67e74705SXin Li 16*67e74705SXin Li 17*67e74705SXin Li@interface I0 { 18*67e74705SXin Li@public 19*67e74705SXin Li char x[4]; 20*67e74705SXin Li} 21*67e74705SXin Li 22*67e74705SXin Li@property int p0; 23*67e74705SXin Li@end 24*67e74705SXin Li 25*67e74705SXin Li// size == 4 26*67e74705SXin Liint g1[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} 27*67e74705SXin Li == 4 ? 1 : -1]; 28*67e74705SXin Li 29*67e74705SXin Li@implementation I0 30*67e74705SXin Li@synthesize p0 = _p0; 31*67e74705SXin Li@end 32*67e74705SXin Li 33*67e74705SXin Li// size == 4 (we do not include extended properties in the 34*67e74705SXin Li// sizeof). 35*67e74705SXin Liint g2[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} 36*67e74705SXin Li == 4 ? 1 : -1]; 37*67e74705SXin Li 38*67e74705SXin Li@interface I1 39*67e74705SXin Li@property int p0; 40*67e74705SXin Li@end 41*67e74705SXin Li 42*67e74705SXin Li@implementation I1 43*67e74705SXin Li@synthesize p0 = _p0; 44*67e74705SXin Li@end 45*67e74705SXin Li 46*67e74705SXin Litypedef struct { @defs(I1); } I1_defs; // expected-error {{use of @defs is not supported on this architecture and platform}} 47*67e74705SXin Li 48*67e74705SXin Li// FIXME: This is currently broken due to the way the record layout we 49*67e74705SXin Li// create is tied to whether we have seen synthesized properties. Ugh. 50*67e74705SXin Li// int g3[ sizeof(I1) == 0 ? 1 : -1]; 51*67e74705SXin Li 52*67e74705SXin Li// rdar://6821047 53*67e74705SXin Liint bar(I0 *P) { 54*67e74705SXin Li P = P+5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} 55*67e74705SXin Li P = 5+P; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} 56*67e74705SXin Li P = P-5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} 57*67e74705SXin Li 58*67e74705SXin Li return P[4].x[2]; // expected-error {{expected method to read array element not found on object of type 'I0 *'}} 59*67e74705SXin Li} 60*67e74705SXin Li 61*67e74705SXin Li 62*67e74705SXin Li@interface I @end 63*67e74705SXin Li 64*67e74705SXin Li@interface XCAttributeRunDirectNode 65*67e74705SXin Li{ 66*67e74705SXin Li @public 67*67e74705SXin Li unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{application of 'sizeof' to interface 'I' is not supported on this architecture and platform}} 68*67e74705SXin Li int i; 69*67e74705SXin Li} 70*67e74705SXin Li@end 71*67e74705SXin Li 72*67e74705SXin Li@implementation XCAttributeRunDirectNode 73*67e74705SXin Li 74*67e74705SXin Li- (unsigned long)gatherStats:(id )stats 75*67e74705SXin Li{ 76*67e74705SXin Li return attributeRuns[i]; 77*67e74705SXin Li} 78*67e74705SXin Li@end 79*67e74705SXin Li 80*67e74705SXin Li 81*67e74705SXin Li@interface Foo @end 82*67e74705SXin Li 83*67e74705SXin Liint foo() 84*67e74705SXin Li{ 85*67e74705SXin Li Foo *f; 86*67e74705SXin Li 87*67e74705SXin Li // Both of these crash clang nicely 88*67e74705SXin Li ++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}} 89*67e74705SXin Li --f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}} 90*67e74705SXin Li} 91