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