diff options
Diffstat (limited to 'clang/test/CodeGen/compound-literal.c')
| -rw-r--r-- | clang/test/CodeGen/compound-literal.c | 15 | 
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/CodeGen/compound-literal.c b/clang/test/CodeGen/compound-literal.c index 38675a7dda2..17a24d47f2f 100644 --- a/clang/test/CodeGen/compound-literal.c +++ b/clang/test/CodeGen/compound-literal.c @@ -11,6 +11,11 @@ _Complex double * x = &(_Complex double){1.0f};  typedef int v4i32 __attribute((vector_size(16)));  v4i32 *y = &(v4i32){1,2,3,4}; +// Check generated code for GNU constant array init from compound literal, +// for a global variable. +// CHECK: @compound_array = global [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8] +int compound_array[] = __extension__(__builtin_choose_expr(0, 0, _Generic(1, int: (int[]){1, 2, 3, 4, 5, 6, 7, 8}))); +  void xxx() {  int* a = &(int){1};  struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; @@ -82,3 +87,13 @@ int compareMyCLH() {    const void *b = MyCLH;    return a == b;  } + +// Check generated code for GNU constant array init from compound literal, +// for a local variable. +// CHECK-LABEL: define i32 @compound_array_fn() +// CHECK: [[COMPOUND_ARRAY:%.*]] = alloca [8 x i32] +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i64 32, i1 false) +int compound_array_fn() { +  int compound_array[] = (int[]){1,2,3,4,5,6,7,8}; +  return compound_array[0]; +}  | 

