Douglas Gregor | 673e98b | 2011-06-17 16:37:20 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s |
Eli Friedman | 06e863f | 2008-05-13 23:18:27 +0000 | [diff] [blame] | 2 | |
| 3 | int* a = &(int){1}; |
| 4 | struct 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 Gregor | 673e98b | 2011-06-17 16:37:20 +0000 | [diff] [blame] | 8 | void xxx() { |
Eli Friedman | 06e863f | 2008-05-13 23:18:27 +0000 | [diff] [blame] | 9 | int* a = &(int){1}; |
| 10 | struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; |
| 11 | _Complex double * x = &(_Complex double){1.0f}; |
Eli Friedman | 06e863f | 2008-05-13 23:18:27 +0000 | [diff] [blame] | 12 | } |
Douglas Gregor | 673e98b | 2011-06-17 16:37:20 +0000 | [diff] [blame] | 13 | |
| 14 | // CHECK: define void @f() |
| 15 | void 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 Gregor | ebfbf9f | 2011-06-17 17:23:28 +0000 | [diff] [blame] | 30 | // CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8* [[SI8]], i8* [[COMPOUNDLITI8]] |
Douglas Gregor | 673e98b | 2011-06-17 16:37:20 +0000 | [diff] [blame] | 31 | s = (S){s.y,s.x}; |
| 32 | // CHECK-NEXT: ret void |
| 33 | } |