mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-25 14:28:54 -04:00

When a function taking transparent union is declared as taking one of union members earlier in the translation unit, clang would hit an "Invalid cast" assertion during EmitFunctionProlog. This case corresponds to function f1 in test/CodeGen/transparent-union-redecl.c. We decided to cast i32 to union because after merging function declarations function parameter type becomes int, CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide it is a trivial case. But these types should also be castable to parameter declaration type which is not the case here. Now the fix is in converting from ABIArgInfo type to VarDecl type and using argument demotion when necessary. Additional tests in Sema/transparent-union.c capture current behavior and make sure there are no regressions. rdar://problem/34949329 Reviewers: rjmccall, rafael Reviewed By: rjmccall Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak Differential Revision: https://reviews.llvm.org/D41311 llvm-svn: 323156
13 lines
361 B
C
13 lines
361 B
C
// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
|
|
|
|
// CHECK: i32 @a(i32
|
|
int a();
|
|
int a(x) short x; {return x;}
|
|
|
|
// CHECK: void @b(double
|
|
// CHECK: %[[ADDR:.*]] = alloca float, align 4
|
|
// CHECK: %[[TRUNC:.*]] = fptrunc double %0 to float
|
|
// CHECK: store float %[[TRUNC]], float* %[[ADDR]], align 4
|
|
void b();
|
|
void b(f) float f; {}
|