summaryrefslogtreecommitdiffstats
path: root/test/Rewriter/rewrite-modern-struct-ivar-1.mm
blob: a17fe3f85675df7b36762d64cec5cc2e112bcbe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp
// 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
// rdar://11323187

typedef unsigned long NSUInteger;

typedef struct _NSRange {
    NSUInteger location;
    NSUInteger length;
} NSRange;

typedef struct {
    NSUInteger _capacity;
    NSRange _ranges[0];
} _NSRangeInfo;

@interface Foo{
    @protected 
    struct _bar {
        int x:1;
        int y:1;
    } bar;
    union {
        struct {
            NSRange _range;
        } _singleRange;
        struct {
            void *  _data;
            void *_reserved;
        } _multipleRanges;
    } _internal;    
}
@end
@implementation Foo
- (void)x:(Foo *)other {
  bar.x = 0;
  bar.y = 1;
  self->_internal._singleRange._range = (( other ->bar.x) ? &( other ->_internal._singleRange._range) : ((NSRange *)(&(((_NSRangeInfo *)( other ->_internal._multipleRanges._data))->_ranges))))[0];
}
@end
@interface FooS : Foo
@end
@implementation FooS
- (void)y {

  NSUInteger asdf =  (( self ->bar.x) ? 1 : ((_NSRangeInfo *)( self ->_internal._multipleRanges._data))->_capacity ); 
}
@end