Fariborz Jahanian | 33eb59a | 2012-02-24 18:17:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -E %s -o %t.mm |
| 2 | // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp |
| 3 | // RUN: FileCheck --input-file=%t-rw.cpp %s |
NAKAMURA Takumi | 9ff009f | 2012-05-01 10:52:06 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -fsyntax-only -Werror -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 |
Fariborz Jahanian | 33eb59a | 2012-02-24 18:17:50 +0000 | [diff] [blame] | 5 | |
| 6 | struct S { |
| 7 | int i1; |
| 8 | double d1; |
| 9 | void (^block1)(); |
| 10 | }; |
| 11 | |
| 12 | @interface I |
| 13 | { |
| 14 | struct S struct_ivar; |
| 15 | |
| 16 | struct S *pstruct_ivar; |
| 17 | } |
| 18 | @end |
| 19 | |
| 20 | @implementation I |
| 21 | - (struct S) dMeth{ return struct_ivar; } |
| 22 | @end |
Fariborz Jahanian | 27fc81b | 2012-04-27 22:48:54 +0000 | [diff] [blame] | 23 | |
Fariborz Jahanian | 7cb2a1b | 2012-03-20 17:13:39 +0000 | [diff] [blame] | 24 | // CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar)); |
Fariborz Jahanian | 27fc81b | 2012-04-27 22:48:54 +0000 | [diff] [blame] | 25 | |
| 26 | // rdar://11323187 |
| 27 | @interface Foo{ |
| 28 | @protected |
| 29 | struct { |
| 30 | int x:1; |
| 31 | int y:1; |
| 32 | } bar; |
| 33 | |
| 34 | struct _S { |
| 35 | int x:1; |
| 36 | int y:1; |
| 37 | } s; |
| 38 | |
| 39 | } |
| 40 | @end |
| 41 | @implementation Foo |
| 42 | - (void)x { |
| 43 | bar.x = 0; |
| 44 | bar.y = 1; |
| 45 | |
| 46 | s.x = 0; |
| 47 | s.y = 1; |
| 48 | } |
| 49 | @end |
| 50 | |
| 51 | // CHECK: (*(decltype(((Foo_IMPL *)0U)->bar) *)((char *)self + OBJC_IVAR_$_Foo$bar)).x = 0; |
Fariborz Jahanian | 8fba894 | 2012-04-30 23:20:30 +0000 | [diff] [blame] | 52 | // CHECK: (*(struct _S *)((char *)self + OBJC_IVAR_$_Foo$s)).x = 0; |