[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / designated-init.cpp
blobd7fca13e78867deb1b8d3e443e4c13e697835e30
1 // RUN: %clang_cc1 -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
2 // RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
4 struct A { int x, y[3]; };
5 struct B { A a; };
7 // CHECK: @b ={{.*}} global %{{[^ ]*}} { %{{[^ ]*}} { i32 1, [3 x i32] [i32 2, i32 5, i32 4] } }
8 B b = {(A){1, 2, 3, 4}, .a.y[1] = 5};
10 union U {
11 int n;
12 float f;
14 struct C {
15 int x;
16 U u[3];
18 struct D {
19 C c;
22 // CHECK: @d1 = {{.*}} { i32 1, [3 x %[[U:.*]]] [%[[U]] { i32 2 }, %[[U]] { i32 5 }, %[[U]] { i32 4 }] }
23 D d1 = {(C){1, {{.n=2}, {.f=3}, {.n=4}}}, .c.u[1].n = 5};
25 // CHECK: @d2 = {{.*}} { i32 1, { %[[U]], float, %[[U]] } { %[[U]] { i32 2 }, float 5.{{0*}}e+00, %[[U]] { i32 4 } } }
26 D d2 = {(C){1, 2, 3, 4}, .c.u[1].f = 5};
28 struct Bitfield {
29 int a : 3;
30 int b : 4;
31 int c : 5;
33 struct WithBitfield {
34 int n;
35 Bitfield b;
37 // CHECK: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
38 WithBitfield bitfield = {1, (Bitfield){2, 3, 4}, .b.b = 5};
40 struct String {
41 const char buffer[12];
43 struct WithString {
44 String str;
46 // CHECK: @string = {{.*}} [12 x i8] c"Hello World\00" } }
47 WithString string = {(String){"hello world"}, .str.buffer[0] = 'H', .str.buffer[6] = 'W'};
49 struct LargeArray {
50 int arr[4096];
52 struct WithLargeArray {
53 LargeArray arr;
55 // CHECK: @large ={{.*}} global { { <{ [11 x i32], [4085 x i32] }> } } { { <{ [11 x i32], [4085 x i32] }> } { <{ [11 x i32], [4085 x i32] }> <{ [11 x i32] [i32 1, i32 2, i32 3, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 10], [4085 x i32] zeroinitializer }> } }
56 WithLargeArray large = {(LargeArray){1, 2, 3}, .arr.arr[10] = 10};
58 union OverwritePaddingWithBitfield {
59 struct Padding { unsigned : 8; char c; } padding;
60 char bitfield : 3;
62 struct WithOverwritePaddingWithBitfield {
63 OverwritePaddingWithBitfield a;
65 // CHECK: @overwrite_padding ={{.*}} global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 } }
66 WithOverwritePaddingWithBitfield overwrite_padding = {(OverwritePaddingWithBitfield){1}, .a.bitfield = 3};