1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s 2 3 struct P1 { 4 struct Q1 { 5 char a[6]; 6 char b[6]; 7 } q; 8 }; 9 10 // CHECK: { [6 x i8] c"foo\00\00\00", [6 x i8] c"\00x\00\00\00\00" } 11 struct P1 l1 = { 12 (struct Q1){ "foo", "bar" }, 13 .q.b = { "boo" }, 14 .q.b = { [1] = 'x' } 15 }; 16 17 // CHECK: { [6 x i8] c"foo\00\00\00", [6 x i8] c"bxo\00\00\00" } 18 struct P1 l1a = { 19 (struct Q1){ "foo", "bar" }, 20 .q.b = { "boo" }, 21 .q.b[1] = 'x' 22 }; 23 24 25 struct P2 { char x[6]; }; 26 27 // CHECK: { [6 x i8] c"n\00\00\00\00\00" } 28 struct P2 l2 = { 29 .x = { [1] = 'o' }, 30 .x = { [0] = 'n' } 31 }; 32 33 struct P3 { 34 struct Q3 { 35 struct R1 { 36 int a, b, c; 37 } r1; 38 39 struct R2 { 40 int d, e, f; 41 } r2; 42 } q; 43 }; 44 45 // CHECK: @l3 = global %struct.P3 { %struct.Q3 { %struct.R1 { i32 1, i32 2, i32 3 }, %struct.R2 { i32 0, i32 10, i32 0 } } } 46 struct P3 l3 = { 47 (struct Q3){ { 1, 2, 3 }, { 4, 5, 6 } }, 48 .q.r2 = { 7, 8, 9 }, 49 .q.r2 = { .e = 10 } 50 }; 51 52 // This bit is taken from Sema/wchar.c so we can avoid the wchar.h include. 53 typedef __WCHAR_TYPE__ wchar_t; 54 55 struct P4 { 56 wchar_t x[6]; 57 }; 58 59 // CHECK: { [6 x i32] [i32 102, i32 111, i32 120, i32 0, i32 0, i32 0] } 60 struct P4 l4 = { { L"foo" }, .x[2] = L'x' }; 61 62 struct P5 { 63 int x; 64 struct Q5 { 65 int a, b, c; 66 } q; 67 int y; 68 }; 69 70 // A three-pass test 71 // CHECK: @l5 = global %struct.P5 { i32 1, %struct.Q5 { i32 6, i32 9, i32 8 }, i32 5 } 72 struct P5 l5 = { 1, { 2, 3, 4 }, 5, 73 .q = { 6, 7, 8 }, 74 .q.b = 9 }; 75