[cfe-commits] r63726 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/Coverage/c-language-features.inc test/Coverage/codegen.c
Daniel Dunbar
daniel at zuster.org
Tue Feb 3 23:22:24 PST 2009
Author: ddunbar
Date: Wed Feb 4 01:22:24 2009
New Revision: 63726
URL: http://llvm.org/viewvc/llvm-project?rev=63726&view=rev
Log:
Handle demotion of coerced arguments (as in void a(x) short x; { ... }).
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/Coverage/c-language-features.inc
cfe/trunk/test/Coverage/codegen.c
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63726&r1=63725&r2=63726&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 4 01:22:24 2009
@@ -1220,8 +1220,14 @@
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;
}
Modified: cfe/trunk/test/Coverage/c-language-features.inc
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/c-language-features.inc?rev=63726&r1=63725&r2=63726&view=diff
==============================================================================
--- cfe/trunk/test/Coverage/c-language-features.inc (original)
+++ cfe/trunk/test/Coverage/c-language-features.inc Wed Feb 4 01:22:24 2009
@@ -144,3 +144,14 @@
const char *s1 = __FUNCTION__;
const char *s2 = __PRETTY_FUNCTION__;
}
+
+// Arg mismatch with passed type.
+void f7(x)
+ float x;
+{
+}
+
+void f8(x)
+ short x;
+{
+}
Modified: cfe/trunk/test/Coverage/codegen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/codegen.c?rev=63726&r1=63725&r2=63726&view=diff
==============================================================================
--- cfe/trunk/test/Coverage/codegen.c (original)
+++ cfe/trunk/test/Coverage/codegen.c Wed Feb 4 01:22:24 2009
@@ -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"
More information about the cfe-commits
mailing list