1 // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp 2 // RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp 3 // rdar://11323187 4 5 typedef unsigned long NSUInteger; 6 7 typedef struct _NSRange { 8 NSUInteger location; 9 NSUInteger length; 10 } NSRange; 11 12 typedef struct { 13 NSUInteger _capacity; 14 NSRange _ranges[0]; 15 } _NSRangeInfo; 16 17 @interface Foo{ 18 @protected 19 struct _bar { 20 int x:1; 21 int y:1; 22 } bar; 23 union { 24 struct { 25 NSRange _range; 26 } _singleRange; 27 struct { 28 void * _data; 29 void *_reserved; 30 } _multipleRanges; 31 } _internal; 32 } 33 @end 34 @implementation Foo 35 - (void)x:(Foo *)other { 36 bar.x = 0; 37 bar.y = 1; 38 self->_internal._singleRange._range = (( other ->bar.x) ? &( other ->_internal._singleRange._range) : ((NSRange *)(&(((_NSRangeInfo *)( other ->_internal._multipleRanges._data))->_ranges))))[0]; 39 } 40 @end 41 @interface FooS : Foo 42 @end 43 @implementation FooS 44 - (void)y { 45 46 NSUInteger asdf = (( self ->bar.x) ? 1 : ((_NSRangeInfo *)( self ->_internal._multipleRanges._data))->_capacity ); 47 } 48 @end 49