transparent-union.c revision de92d739ba0ef42a5a7dcfd6e170329549d0716b
14846675e0e42d1802b0ffd8972a45e72aeb3758dPeter Collingbourne// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s
241e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar// RUN: FileCheck < %t %s
341e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar//
441e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar// FIXME: Note that we don't currently get the ABI right here. f0() should be
541e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar// f0(i8*).
641e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar
741e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbartypedef union {
841e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar  void *f0;
941e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar} transp_t0 __attribute__((transparent_union));
1041e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar
1141e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbarvoid f0(transp_t0 obj);
1241e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar
1341e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar// CHECK: define void @f1_0(i32* %a0)
14de92d739ba0ef42a5a7dcfd6e170329549d0716bChris Lattner// CHECK:  call void @f0(%union.transp_t0* byval align 4 %{{.*}})
154846675e0e42d1802b0ffd8972a45e72aeb3758dPeter Collingbourne// CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
1641e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar// CHECK: }
1741e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbarvoid f1_0(int *a0) {
184846675e0e42d1802b0ffd8972a45e72aeb3758dPeter Collingbourne  void (*f0p)(void *) = f0;
1941e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar  f0(a0);
204846675e0e42d1802b0ffd8972a45e72aeb3758dPeter Collingbourne  f0p(a0);
2141e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar}
2241e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar
2341e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbarvoid f1_1(int *a0) {
2441e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar  f0((transp_t0) { a0 });
2541e11a9315f7041c93e409f5d372013204e7cd04Daniel Dunbar}
26