diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-04 07:22:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-04 07:22:24 +0000 |
commit | 8b29a387788bbb7a7c3b64c37473bc46299d2132 (patch) | |
tree | e22452087d5ea06b52676fc72b6fabf62d965cd5 | |
parent | 137b6a6149c53dbbcb8fba98e524d9ad0f3c8736 (diff) |
Handle demotion of coerced arguments (as in void a(x) short x; { ... }).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63726 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGCall.cpp | 8 | ||||
-rw-r--r-- | test/Coverage/c-language-features.inc | 11 | ||||
-rw-r--r-- | test/Coverage/codegen.c | 8 |
3 files changed, 23 insertions, 4 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 8967ffbfc9..2ad8f917e1 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/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/test/Coverage/c-language-features.inc b/test/Coverage/c-language-features.inc index 9a52e56c21..8b56e6a55b 100644 --- a/test/Coverage/c-language-features.inc +++ b/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/test/Coverage/codegen.c b/test/Coverage/codegen.c index 8c9ce02d7c..5d6724ed2f 100644 --- a/test/Coverage/codegen.c +++ b/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" |