38 lines · c
1// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s2 3void escape(const void *);4 5// CHECK-DAG: internal global i8 996 7void T1(void) {8 const char *x[1] = {({static char _x = 99; &_x; })};9 escape(x);10}11 12struct sized_array {13 int count;14 int entries[];15};16 17#define N_ARGS(...) (sizeof((int[]){__VA_ARGS__}) / sizeof(int))18 19#define ARRAY_PTR(...) ({ \20 static const struct sized_array _a = {N_ARGS(__VA_ARGS__), {__VA_ARGS__}}; \21 &_a; \22})23 24struct outer {25 const struct sized_array *a;26};27 28void T2(void) {29 // CHECK-DAG: internal constant { i32, [2 x i32] } { i32 2, [2 x i32] [i32 50, i32 60] }30 const struct sized_array *A = ARRAY_PTR(50, 60);31 32 // CHECK-DAG: internal constant { i32, [3 x i32] } { i32 3, [3 x i32] [i32 10, i32 20, i32 30] }33 struct outer X = {ARRAY_PTR(10, 20, 30)};34 35 escape(A);36 escape(&X);37}38