diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-28 16:23:54 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-28 16:23:54 +0000 |
commit | d8417784e415cefba220c8fae5f6de4322a539de (patch) | |
tree | 31d8723d99f10a1d2dd3a4184c65729048056a59 /test/CodeGenCXX/conversion-function.cpp | |
parent | 83b534cb4329a49e265776dba3e87dc7032174be (diff) |
Test case for conversion type method call ir-gen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80375 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/conversion-function.cpp')
-rw-r--r-- | test/CodeGenCXX/conversion-function.cpp | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/test/CodeGenCXX/conversion-function.cpp b/test/CodeGenCXX/conversion-function.cpp index 57e5ad7315..5961157951 100644 --- a/test/CodeGenCXX/conversion-function.cpp +++ b/test/CodeGenCXX/conversion-function.cpp @@ -1,9 +1,65 @@ -// RUN: clang-cc %s -emit-llvm -o %t && +// 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 S { operator int(); }; -// RUN: grep "_ZN1ScviEv" %t S::operator int() { return 10; } + + +class X { // ... + public: operator int() { printf("operator int()\n"); return iX; } + public: operator float() { printf("operator float()\n"); return fX; } + X() : iX(100), fX(1.234) {} + int iX; + float fX; +}; + +X x; + +struct Z { + operator X() { printf("perator X()\n"); x.iX += iZ; x.fX += fZ; return x; } + int iZ; + float fZ; + Z() : iZ(1), fZ(1.00) {} +}; + +Z z; + +class Y { // ... + public: operator Z(){printf("perator Z()\n"); return z; } +}; + +Y y; + +int main() { + int c = X(Z(y)); // OK: y.operator Z().operator X().operator int() + printf("c = %d\n", c); + float f = X(Z(y)); + printf("f = %f\n", f); + int i = x; + printf("i = %d float = %f\n", i, float(x)); + i = int(X(Z(y))); + f = float(X(Z(y))); + printf("i = %d float = %f\n", i,f); +} +// CHECK-LP64: .globl __ZN1ScviEv +// CHECK-LP64-NEXT: __ZN1ScviEv: +// CHECK-LP64: call __ZN1Ycv1ZEv +// CHECK-LP64: call __ZN1Zcv1XEv +// CHECK-LP64: call __ZN1XcviEv +// CHECK-LP64: call __ZN1XcvfEv + +// CHECK-LP32: .globl __ZN1ScviEv +// CHECK-LP32-NEXT: __ZN1ScviEv: +// CHECK-LP32: call L__ZN1Ycv1ZEv +// CHECK-LP32: call L__ZN1Zcv1XEv +// CHECK-LP32: call L__ZN1XcviEv +// CHECK-LP32: call L__ZN1XcvfEv |