diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-16 19:20:59 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-16 19:20:59 +0000 |
commit | 93034ca3d025e948ddfcdd78868957efc70741a7 (patch) | |
tree | a9692cb94b58f7565f820783443dcd26687f3646 /test/CodeGenCXX/derived-to-base-conv.cpp | |
parent | 52e7108f51a4a9f4d6e84f33fb594d06e1d79560 (diff) |
Implement derived-to-base AST/code gen. There is a
FIXME in CGCXX.cpp that I would like Anders to
take a look at.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/derived-to-base-conv.cpp')
-rw-r--r-- | test/CodeGenCXX/derived-to-base-conv.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp new file mode 100644 index 0000000000..218116e346 --- /dev/null +++ b/test/CodeGenCXX/derived-to-base-conv.cpp @@ -0,0 +1,51 @@ +// 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 + +extern "C" int printf(...); + +struct A { + A (const A&) { printf("A::A(const A&)\n"); } + A() {}; +}; + +struct B : public A { + B() {}; +}; + +struct C : public B { + C() {}; +}; + +struct X { + operator B&() {printf("X::operator B&()\n"); return b; } + operator C&() {printf("X::operator C&()\n"); return c; } + X (const X&) { printf("X::X(const X&)\n"); } + X () { printf("X::X()\n"); } + B b; + C c; +}; + +void f(A) { + printf("f(A)\n"); +} + + +void func(X x) +{ + f (x); +} + +int main() +{ + X x; + func(x); +} + +// CHECK-LP64: call __ZN1XcvR1BEv +// CHECK-LP64: call __ZN1AC1ERKS_ + +// CHECK-LP32: call L__ZN1XcvR1BEv +// CHECK-LP32: call L__ZN1AC1ERKS_ |