xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/transparent-union.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s
2*f4a2713aSLionel Sambuc // RUN: FileCheck < %t %s
3*f4a2713aSLionel Sambuc //
4*f4a2713aSLionel Sambuc // FIXME: Note that we don't currently get the ABI right here. f0() should be
5*f4a2713aSLionel Sambuc // f0(i8*).
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc typedef union {
8*f4a2713aSLionel Sambuc   void *f0;
9*f4a2713aSLionel Sambuc } transp_t0 __attribute__((transparent_union));
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc void f0(transp_t0 obj);
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f1_0(i32* %a0)
14*f4a2713aSLionel Sambuc // CHECK:  call void @f0(%union.transp_t0* byval align 4 %{{.*}})
15*f4a2713aSLionel Sambuc // CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
16*f4a2713aSLionel Sambuc // CHECK: }
17*f4a2713aSLionel Sambuc void f1_0(int *a0) {
18*f4a2713aSLionel Sambuc   void (*f0p)(void *) = f0;
19*f4a2713aSLionel Sambuc   f0(a0);
20*f4a2713aSLionel Sambuc   f0p(a0);
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc void f1_1(int *a0) {
24*f4a2713aSLionel Sambuc   f0((transp_t0) { a0 });
25*f4a2713aSLionel Sambuc }
26