Clang Project

clang_source_code/test/CodeGen/transparent-union.c
1// RUN: %clang_cc1 -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
2// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
3// RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
4// RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
5// RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
6// RUN: %clang_cc1 -DINFRONT -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
7// RUN: %clang_cc1 -DINFRONT -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
8// RUN: %clang_cc1 -DINFRONT -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
9// RUN: %clang_cc1 -DINFRONT -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
10// RUN: %clang_cc1 -DINFRONT -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
11
12#ifdef INFRONT
13typedef union __attribute__((transparent_union)) {
14  void *f0;
15} transp_t0;
16#else
17typedef union {
18  void *f0;
19} transp_t0 __attribute__((transparent_union));
20#endif
21
22void f0(transp_t0 obj);
23
24// CHECK-LABEL: define void @f1_0(i32* %a0)
25// CHECK:  call void @f0(i8* %{{.*}})
26// CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
27// CHECK: }
28
29// ARM-LABEL: define arm_aapcscc void @f1_0(i32* %a0)
30// ARM:  call arm_aapcscc void @f0(i8* %{{.*}})
31// ARM:  call arm_aapcscc void %{{.*}}(i8* %{{[a-z0-9]*}})
32// ARM: }
33void f1_0(int *a0) {
34  void (*f0p)(void *) = f0;
35  f0(a0);
36  f0p(a0);
37}
38
39void f1_1(int *a0) {
40  f0((transp_t0) { a0 });
41}
42