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 | da21efb5669868f5a1736608d79cf1e1ddcb67b5 (patch) | |
tree | 077a6470c7dd4a0131cb8550dfe1ff55ce4fe5e0 /clang/test/CodeGenCXX/derived-to-base-conv.cpp | |
parent | 8f842d31fd6d609a1ff0856da2aa3e660d0cf120 (diff) | |
download | bcm5719-llvm-da21efb5669868f5a1736608d79cf1e1ddcb67b5.tar.gz bcm5719-llvm-da21efb5669868f5a1736608d79cf1e1ddcb67b5.zip |
Implement derived-to-base AST/code gen. There is a
FIXME in CGCXX.cpp that I would like Anders to
take a look at.
llvm-svn: 84265
Diffstat (limited to 'clang/test/CodeGenCXX/derived-to-base-conv.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/derived-to-base-conv.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/derived-to-base-conv.cpp b/clang/test/CodeGenCXX/derived-to-base-conv.cpp new file mode 100644 index 00000000000..218116e346d --- /dev/null +++ b/clang/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_ |