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