blob: 0164c2b738621d87dcb58fa5b4307d4e36ce6887 [file] [log] [blame]
Douglas Gregor673e98b2011-06-17 16:37:20 +00001// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
Eli Friedman06e863f2008-05-13 23:18:27 +00002
3int* a = &(int){1};
4struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
5// Not working; complex constants are broken
6// _Complex double * x = &(_Complex double){1.0f};
7
Douglas Gregor673e98b2011-06-17 16:37:20 +00008void xxx() {
Eli Friedman06e863f2008-05-13 23:18:27 +00009int* a = &(int){1};
10struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
11_Complex double * x = &(_Complex double){1.0f};
Eli Friedman06e863f2008-05-13 23:18:27 +000012}
Douglas Gregor673e98b2011-06-17 16:37:20 +000013
14// CHECK: define void @f()
15void f() {
16 typedef struct S { int x,y; } S;
17 // CHECK: [[S:%[a-zA-Z0-9.]+]] = alloca [[STRUCT:%[a-zA-Z0-9.]+]],
18 struct S s;
19 // CHECK-NEXT: [[COMPOUNDLIT:%[a-zA-Z0-9.]+]] = alloca [[STRUCT]]
20 // CHECK-NEXT: [[CX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 0
21 // CHECK-NEXT: [[SY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 1
22 // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SY]]
23 // CHECK-NEXT: store i32 [[TMP]], i32* [[CX]]
24 // CHECK-NEXT: [[CY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 1
25 // CHECK-NEXT: [[SX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 0
26 // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SX]]
27 // CHECK-NEXT: store i32 [[TMP]], i32* [[CY]]
28 // CHECK-NEXT: [[SI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[S]] to i8*
29 // CHECK-NEXT: [[COMPOUNDLITI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[COMPOUNDLIT]] to i8*
Douglas Gregorebfbf9f2011-06-17 17:23:28 +000030 // CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8* [[SI8]], i8* [[COMPOUNDLITI8]]
Douglas Gregor673e98b2011-06-17 16:37:20 +000031 s = (S){s.y,s.x};
32 // CHECK-NEXT: ret void
33}