xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-modern-struct-ivar-1.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp
2*f4a2713aSLionel Sambuc// 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*f4a2713aSLionel Sambuc// rdar://11323187
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuctypedef unsigned long NSUInteger;
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuctypedef struct _NSRange {
8*f4a2713aSLionel Sambuc    NSUInteger location;
9*f4a2713aSLionel Sambuc    NSUInteger length;
10*f4a2713aSLionel Sambuc} NSRange;
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuctypedef struct {
13*f4a2713aSLionel Sambuc    NSUInteger _capacity;
14*f4a2713aSLionel Sambuc    NSRange _ranges[0];
15*f4a2713aSLionel Sambuc} _NSRangeInfo;
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc@interface Foo{
18*f4a2713aSLionel Sambuc    @protected
19*f4a2713aSLionel Sambuc    struct _bar {
20*f4a2713aSLionel Sambuc        int x:1;
21*f4a2713aSLionel Sambuc        int y:1;
22*f4a2713aSLionel Sambuc    } bar;
23*f4a2713aSLionel Sambuc    union {
24*f4a2713aSLionel Sambuc        struct {
25*f4a2713aSLionel Sambuc            NSRange _range;
26*f4a2713aSLionel Sambuc        } _singleRange;
27*f4a2713aSLionel Sambuc        struct {
28*f4a2713aSLionel Sambuc            void *  _data;
29*f4a2713aSLionel Sambuc            void *_reserved;
30*f4a2713aSLionel Sambuc        } _multipleRanges;
31*f4a2713aSLionel Sambuc    } _internal;
32*f4a2713aSLionel Sambuc}
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc@implementation Foo
35*f4a2713aSLionel Sambuc- (void)x:(Foo *)other {
36*f4a2713aSLionel Sambuc  bar.x = 0;
37*f4a2713aSLionel Sambuc  bar.y = 1;
38*f4a2713aSLionel Sambuc  self->_internal._singleRange._range = (( other ->bar.x) ? &( other ->_internal._singleRange._range) : ((NSRange *)(&(((_NSRangeInfo *)( other ->_internal._multipleRanges._data))->_ranges))))[0];
39*f4a2713aSLionel Sambuc}
40*f4a2713aSLionel Sambuc@end
41*f4a2713aSLionel Sambuc@interface FooS : Foo
42*f4a2713aSLionel Sambuc@end
43*f4a2713aSLionel Sambuc@implementation FooS
44*f4a2713aSLionel Sambuc- (void)y {
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc  NSUInteger asdf =  (( self ->bar.x) ? 1 : ((_NSRangeInfo *)( self ->_internal._multipleRanges._data))->_capacity );
47*f4a2713aSLionel Sambuc}
48*f4a2713aSLionel Sambuc@end
49