]> granicus.if.org Git - clang/commitdiff
This patch fixes code gen. part of pr5333 (Conversion
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 6 Nov 2009 18:47:57 +0000 (18:47 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 6 Nov 2009 18:47:57 +0000 (18:47 +0000)
using elipsis conversion).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86276 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/vararg-conversion-ctor.cpp [new file with mode: 0644]

index 0e6b5cb14341411e4843c68bc44de74d7b84925b..cc6f13be1a649d580e48560e52d6da63a999e3ba 100644 (file)
@@ -649,8 +649,10 @@ void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *D,
 llvm::Function *
 CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
                                        CXXCtorType Type) {
+  const FunctionProtoType *FPT = D->getType()->getAs<FunctionProtoType>();
   const llvm::FunctionType *FTy =
-    getTypes().GetFunctionType(getTypes().getFunctionInfo(D), false);
+    getTypes().GetFunctionType(getTypes().getFunctionInfo(D), 
+                               FPT->isVariadic());
 
   const char *Name = getMangledCXXCtorName(D, Type);
   return cast<llvm::Function>(
diff --git a/test/CodeGenCXX/vararg-conversion-ctor.cpp b/test/CodeGenCXX/vararg-conversion-ctor.cpp
new file mode 100644 (file)
index 0000000..d6110b7
--- /dev/null
@@ -0,0 +1,24 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll &&
+// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s &&
+// RUN: true
+
+extern "C" int printf(...);
+
+struct A { 
+  A(...) {
+    printf("A::A(...)\n"); 
+  } 
+};
+
+A a(1.34);
+
+A b = 2.34;
+
+int main()
+{
+  A c[3];
+}
+
+// CHECK-LPLL64: call void (%struct.A*, ...)
+// CHECK-LPLL64: call void (%struct.A*, ...)
+// CHECK-LPLL64: call void (%struct.A*, ...)