[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / flexible-array-init.cpp
blobd067a614e1afe5da1d8d9dc4fb08323cd175f745
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ -emit-llvm -o - %s | FileCheck %s
3 union _u { char a[]; } u = {};
4 union _u0 { char a[]; } u0 = {0};
6 // CHECK: %union._u = type { [0 x i8] }
8 // CHECK: @u = global %union._u zeroinitializer, align 1
9 // CHECK: @u0 = global { [1 x i8] } zeroinitializer, align 1
11 union { char a[]; } z = {};
12 // CHECK: @z = internal global %union.{{.*}} zeroinitializer, align 1
13 union { char a[]; } z0 = {0};
14 // CHECK: @z0 = internal global { [1 x i8] } zeroinitializer, align 1
16 /* C++ requires global anonymous unions have static storage, so we have to
17 reference them to keep them in the IR output. */
18 char keep(int pick)
20 if (pick)
21 return z.a[0];
22 else
23 return z0.a[0];