| 1 |
// RUN: %clang_cc1 -Werror -triple i386-linux -Wno-strict-prototypes -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
// Test that different order of declarations is acceptable and that |
| 4 |
// implementing different redeclarations is acceptable. |
| 5 |
|
| 6 |
typedef union { |
| 7 |
int i; |
| 8 |
float f; |
| 9 |
} TU __attribute__((transparent_union)); |
| 10 |
|
| 11 |
// CHECK-LABEL: define{{.*}} void @f0(i32 %tu.coerce) |
| 12 |
// CHECK: %tu = alloca %union.TU, align 4 |
| 13 |
// CHECK: %coerce.dive = getelementptr inbounds nuw %union.TU, ptr %tu, i32 0, i32 0 |
| 14 |
// CHECK: store i32 %tu.coerce, ptr %coerce.dive, align 4 |
| 15 |
void f0(TU tu) {} |
| 16 |
void f0(int i); |
| 17 |
|
| 18 |
// CHECK-LABEL: define{{.*}} void @f1(i32 noundef %tu.coerce) |
| 19 |
// CHECK: %tu = alloca %union.TU, align 4 |
| 20 |
// CHECK: %coerce.dive = getelementptr inbounds nuw %union.TU, ptr %tu, i32 0, i32 0 |
| 21 |
// CHECK: store i32 %tu.coerce, ptr %coerce.dive, align 4 |
| 22 |
void f1(int i); |
| 23 |
void f1(TU tu) {} |
| 24 |
|
| 25 |
// CHECK-LABEL: define{{.*}} void @f2(i32 noundef %i) |
| 26 |
// CHECK: %i.addr = alloca i32, align 4 |
| 27 |
// CHECK: store i32 %i, ptr %i.addr, align 4 |
| 28 |
void f2(TU tu); |
| 29 |
void f2(int i) {} |
| 30 |
|
| 31 |
// CHECK-LABEL: define{{.*}} void @f3(i32 noundef %i) |
| 32 |
// CHECK: %i.addr = alloca i32, align 4 |
| 33 |
// CHECK: store i32 %i, ptr %i.addr, align 4 |
| 34 |
void f3(int i) {} |
| 35 |
void f3(TU tu); |
| 36 |
|
| 37 |
// Also test functions with parameters specified K&R style. |
| 38 |
// CHECK-LABEL: define{{.*}} void @knrStyle(i32 noundef %tu.coerce) |
| 39 |
// CHECK: %tu = alloca %union.TU, align 4 |
| 40 |
// CHECK: %coerce.dive = getelementptr inbounds nuw %union.TU, ptr %tu, i32 0, i32 0 |
| 41 |
// CHECK: store i32 %tu.coerce, ptr %coerce.dive, align 4 |
| 42 |
void knrStyle(int i); |
| 43 |
void knrStyle(tu) TU tu; {} |