Daniel Dunbar | 1af336e | 2009-04-22 17:43:55 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple x86_64-apple-darwin9 -emit-llvm -o %t %s && |
| 2 | // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && |
| 3 | |
| 4 | // RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_const", align 8' %t && |
| 5 | // RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_const", align 8' %t && |
| 6 | // RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 16, section "__DATA, __objc_const", align 8' %t && |
| 7 | // RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 24, section "__DATA, __objc_const", align 8' %t && |
| 8 | // RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = global i64 28, section "__DATA, __objc_const", align 8' %t && |
| 9 | // RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = global i64 32, section "__DATA, __objc_const", align 8' %t && |
Daniel Dunbar | 7838752 | 2009-05-04 21:26:30 +0000 | [diff] [blame] | 10 | // RUN: grep '_OBJC_CLASS_RO_$_I6" = internal global .* { i32 2, i32 0, i32 1, .*' %t && |
| 11 | // RUN: grep '_OBJC_CLASS_RO_$_I8" = internal global .* { i32 0, i32 8, i32 16, .*' %t && |
Daniel Dunbar | 1af336e | 2009-04-22 17:43:55 +0000 | [diff] [blame] | 12 | |
| 13 | // RUN: true |
| 14 | |
| 15 | struct s0 { |
| 16 | double x; |
| 17 | }; |
| 18 | |
| 19 | @interface I2 { |
| 20 | struct s0 _iv1; |
| 21 | } |
| 22 | @end |
| 23 | |
| 24 | @interface I3 : I2 { |
| 25 | unsigned int _iv2 :1; |
| 26 | unsigned : 0; |
| 27 | unsigned int _iv3 : 3; |
| 28 | } |
| 29 | @end |
| 30 | |
| 31 | @interface I4 : I3 { |
| 32 | char _iv4; |
| 33 | } |
| 34 | @end |
| 35 | |
| 36 | @interface I5 : I4 { |
| 37 | char _iv5; |
| 38 | } |
| 39 | |
| 40 | @property int prop0; |
| 41 | @end |
| 42 | |
| 43 | @implementation I3 |
| 44 | @end |
| 45 | |
| 46 | @implementation I4 |
| 47 | @end |
| 48 | |
| 49 | @interface I5 () |
| 50 | @property int prop1; |
| 51 | @property char prop2; |
| 52 | @end |
| 53 | |
| 54 | @implementation I5 |
| 55 | @synthesize prop0 = _iv6_synth; |
| 56 | @synthesize prop1 = _iv7_synth; |
| 57 | @synthesize prop2 = _iv5; |
| 58 | @end |
Daniel Dunbar | 7838752 | 2009-05-04 21:26:30 +0000 | [diff] [blame] | 59 | |
| 60 | // The size rounds up to the next available byte. |
| 61 | @interface I6 { |
| 62 | unsigned iv0 : 2; |
| 63 | } |
| 64 | @end |
| 65 | @implementation I6 |
| 66 | @end |
| 67 | |
| 68 | // The start of the subclass includes padding for its own alignment. |
| 69 | @interface I7 { |
| 70 | char a; |
| 71 | } |
| 72 | @end |
| 73 | @interface I8 : I7 { |
| 74 | double b; |
| 75 | } |
| 76 | @end |
| 77 | @implementation I8 |
| 78 | @end |
| 79 | |