summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/kr-func-promote.c
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2018-01-22 22:29:24 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2018-01-22 22:29:24 +0000
commit17ebdb239fee0bf6c349c13445ad9ec476552b59 (patch)
tree2f98e111630896e5a940861c04922d99b668ccfa /clang/test/CodeGen/kr-func-promote.c
parentc58f2166ab3987f37cb0d7815b561bff5a20a69a (diff)
downloadbcm5719-llvm-17ebdb239fee0bf6c349c13445ad9ec476552b59.tar.gz
bcm5719-llvm-17ebdb239fee0bf6c349c13445ad9ec476552b59.zip
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."
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
Diffstat (limited to 'clang/test/CodeGen/kr-func-promote.c')
-rw-r--r--clang/test/CodeGen/kr-func-promote.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/test/CodeGen/kr-func-promote.c b/clang/test/CodeGen/kr-func-promote.c
index 8e55dc91edf..122e6435d0b 100644
--- a/clang/test/CodeGen/kr-func-promote.c
+++ b/clang/test/CodeGen/kr-func-promote.c
@@ -1,6 +1,12 @@
// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
-// CHECK: i32 @a(i32)
+// 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; {}
OpenPOWER on IntegriCloud