]> granicus.if.org Git - clang/commitdiff
Handle demotion of coerced arguments (as in void a(x) short x; { ... }).
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 07:22:24 +0000 (07:22 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Feb 2009 07:22:24 +0000 (07:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63726 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
test/Coverage/c-language-features.inc
test/Coverage/codegen.c

index 8967ffbfc9b2b2a835eb609b9f6061d017562d7c..2ad8f917e117d2e610cdb02ed5e948597c35321c 100644 (file)
@@ -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;
     }
index 9a52e56c21d5d98994d9789bc9f47124148ab3d0..8b56e6a55b69c3c729be147b87f4110b4b430fa4 100644 (file)
@@ -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;
+{
+}
index 8c9ce02d7cf48015879a98a14a7a01440a1b43ed..5d6724ed2fa8860a7b2d084485283168142bd7cf 100644 (file)
@@ -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"