summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-04 07:22:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-04 07:22:24 +0000
commit6e3b7df125333ee7d1fbee853beddafda01c9e18 (patch)
tree73a5b85cf51a0a353719c58f1a709b56a05f5656
parent0649abdfe2c44352a6518c2d2c1606e7bcbb7063 (diff)
downloadbcm5719-llvm-6e3b7df125333ee7d1fbee853beddafda01c9e18.tar.gz
bcm5719-llvm-6e3b7df125333ee7d1fbee853beddafda01c9e18.zip
Handle demotion of coerced arguments (as in void a(x) short x; { ... }).
llvm-svn: 63726
-rw-r--r--clang/lib/CodeGen/CGCall.cpp8
-rw-r--r--clang/test/Coverage/c-language-features.inc11
-rw-r--r--clang/test/Coverage/codegen.c8
3 files changed, 23 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 8967ffbfc9b..2ad8f917e11 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1220,8 +1220,14 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
llvm::Value *V = CreateTempAlloca(ConvertType(Ty), "coerce");
CreateCoercedStore(AI, V, *this);
// Match to what EmitParmDecl is expecting for this type.
- if (!CodeGenFunction::hasAggregateLLVMType(Ty))
+ if (!CodeGenFunction::hasAggregateLLVMType(Ty)) {
V = Builder.CreateLoad(V);
+ if (!getContext().typesAreCompatible(Ty, Arg->getType())) {
+ // This must be a promotion, for something like
+ // "void a(x) short x; {..."
+ V = EmitScalarConversion(V, Ty, Arg->getType());
+ }
+ }
EmitParmDecl(*Arg, V);
break;
}
diff --git a/clang/test/Coverage/c-language-features.inc b/clang/test/Coverage/c-language-features.inc
index 9a52e56c21d..8b56e6a55b6 100644
--- a/clang/test/Coverage/c-language-features.inc
+++ b/clang/test/Coverage/c-language-features.inc
@@ -144,3 +144,14 @@ void f6() {
const char *s1 = __FUNCTION__;
const char *s2 = __PRETTY_FUNCTION__;
}
+
+// Arg mismatch with passed type.
+void f7(x)
+ float x;
+{
+}
+
+void f8(x)
+ short x;
+{
+}
diff --git a/clang/test/Coverage/codegen.c b/clang/test/Coverage/codegen.c
index 8c9ce02d7cf..5d6724ed2fa 100644
--- a/clang/test/Coverage/codegen.c
+++ b/clang/test/Coverage/codegen.c
@@ -1,5 +1,7 @@
-// RUN: clang -emit-llvm -o %t %s &&
-// RUN: clang -emit-llvm-bc -o %t %s &&
-// RUN: clang -g -emit-llvm-bc -o %t %s
+// RUN: clang -triple i386-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang -triple i386-unknown-unknown -emit-llvm-bc -o %t %s &&
+// RUN: clang -triple i386-unknown-unknown -g -emit-llvm-bc -o %t %s &&
+// RUN: clang -triple x86_64-unknown-unknown -emit-llvm-bc -o %t %s &&
+// RUN: clang -triple x86_64-unknown-unknown -g -emit-llvm-bc -o %t %s
#include "c-language-features.inc"
OpenPOWER on IntegriCloud