[cfe-commits] r82783 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/PR5050-constructor-conversion.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Sep 25 11:11:25 PDT 2009
Author: fjahanian
Date: Fri Sep 25 13:11:25 2009
New Revision: 82783
URL: http://llvm.org/viewvc/llvm-project?rev=82783&view=rev
Log:
Fix the AST tree so ir-gen can do the conversion via copy construction.
Fixed pr5050.
Added:
cfe/trunk/test/CodeGenCXX/PR5050-constructor-conversion.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=82783&r1=82782&r2=82783&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 25 13:11:25 2009
@@ -1113,7 +1113,9 @@
if (SCS.CopyConstructor) {
// FIXME: When can ToType be a reference type?
assert(!ToType->isReferenceType());
-
+ if (SCS.Second == ICK_Derived_To_Base)
+ ImpCastExprToType(From, ToType, CastExpr::CK_DerivedToBase,
+ /*isLvalue=*/true);
OwningExprResult FromResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType, SCS.CopyConstructor,
Added: cfe/trunk/test/CodeGenCXX/PR5050-constructor-conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR5050-constructor-conversion.cpp?rev=82783&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR5050-constructor-conversion.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/PR5050-constructor-conversion.cpp Fri Sep 25 13:11:25 2009
@@ -0,0 +1,19 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s &&
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
+// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s &&
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
+// RUN: true
+
+struct A { A(const A&); };
+
+struct B : A { };
+
+A f(const B &b) {
+ return b;
+}
+
+// CHECK-LP64: call __ZN1AC1ERK1A
+
+// CHECK-LP32: call L__ZN1AC1ERK1A
+
+
More information about the cfe-commits
mailing list