]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/transparent-union-redecl.c
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / CodeGen / transparent-union-redecl.c
1 // RUN: %clang_cc1 -Werror -triple i386-linux -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 // rdar://problem/34949329
6
7 typedef union {
8   int i;
9   float f;
10 } TU __attribute__((transparent_union));
11
12 // CHECK-LABEL: define void @f0(i32 %tu.coerce)
13 // CHECK: %tu = alloca %union.TU, align 4
14 // CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
15 // CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
16 void f0(TU tu) {}
17 void f0(int i);
18
19 // CHECK-LABEL: define void @f1(i32 %tu.coerce)
20 // CHECK: %tu = alloca %union.TU, align 4
21 // CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
22 // CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
23 void f1(int i);
24 void f1(TU tu) {}
25
26 // CHECK-LABEL: define void @f2(i32 %i)
27 // CHECK: %i.addr = alloca i32, align 4
28 // CHECK: store i32 %i, i32* %i.addr, align 4
29 void f2(TU tu);
30 void f2(int i) {}
31
32 // CHECK-LABEL: define void @f3(i32 %i)
33 // CHECK: %i.addr = alloca i32, align 4
34 // CHECK: store i32 %i, i32* %i.addr, align 4
35 void f3(int i) {}
36 void f3(TU tu);
37
38 // Also test functions with parameters specified K&R style.
39 // CHECK-LABEL: define void @knrStyle(i32 %tu.coerce)
40 // CHECK: %tu = alloca %union.TU, align 4
41 // CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
42 // CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
43 void knrStyle(int i);
44 void knrStyle(tu) TU tu; {}