| 1 |
/* RUN: %clang_cc1 -std=c89 -emit-llvm -o - %s | FileCheck %s |
| 2 |
RUN: %clang_cc1 -std=c99 -emit-llvm -o - %s | FileCheck %s |
| 3 |
RUN: %clang_cc1 -std=c11 -emit-llvm -o - %s | FileCheck %s |
| 4 |
RUN: %clang_cc1 -std=c17 -emit-llvm -o - %s | FileCheck %s |
| 5 |
RUN: %clang_cc1 -std=c2x -emit-llvm -o - %s | FileCheck %s |
| 6 |
*/ |
| 7 |
|
| 8 |
/* WG14 DR094: yes |
| 9 |
* Are constraints on function return the same as assignment? |
| 10 |
*/ |
| 11 |
|
| 12 |
float func(void) { return 1.0f; } |
| 13 |
void other_func(void) { |
| 14 |
int i; |
| 15 |
float f; |
| 16 |
|
| 17 |
/* Test that there's been a conversion from float to int. */ |
| 18 |
i = func(); |
| 19 |
// CHECK: %call = call float @func() |
| 20 |
// CHECK-NEXT: %conv = fptosi float %call to i32 |
| 21 |
// CHECK-NEXT: store i32 %conv, ptr %i, align 4 |
| 22 |
|
| 23 |
/* Test that the conversion looks the same as an assignment. */ |
| 24 |
i = f; |
| 25 |
// CHECK: %0 = load float, ptr %f, align 4 |
| 26 |
// CHECK-NEXT: %conv1 = fptosi float %0 to i32 |
| 27 |
// CHECK-NEXT: store i32 %conv1, ptr %i, align 4 |
| 28 |
} |
| 29 |
|