1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
2 // RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s
3 // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
4 // RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s
6 extern "C" int printf(...);
20 public: operator int() { printf("operator int()\n"); return iX; }
21 public: operator float() { printf("operator float()\n"); return fX; }
22 X() : iX(100), fX(1.234) {}
30 operator X() { printf("perator X()\n"); x.iX += iZ; x.fX += fZ; return x; }
33 Z() : iZ(1), fZ(1.00) {}
39 public: operator Z(){printf("perator Z()\n"); return z; }
47 operator int(){ return ++iO; }
53 int i = (a) ? 1+a : 0;
54 int j = (a&&b) ? a+b : i;
56 printf("i = %d j = %d a.iO = %d b.iO = %d\n", i, j, a.iO, b.iO);
60 int c = X(Z(y)); // OK: y.operator Z().operator X().operator int()
61 printf("c = %d\n", c);
63 printf("f = %f\n", f);
65 printf("i = %d float = %f\n", i, float(x));
68 printf("i = %d float = %f\n", i,f);
71 printf("i = %d float = %f\n", i,f);
74 printf("d = %d\n", d);
76 int e = (int)((X)((Z)y));
77 printf("e = %d\n", e);
82 // Test. Conversion in base class is visible in derived class.
89 class Yb : public XB {
96 int i = a; // OK. calls XB::operator int();
97 char ch = a; // OK. calls Yb::operator char();
101 operator int() const;
104 // CHECK-LP64: .globl __ZN1ScviEv
105 // CHECK-LP64-NEXT: __ZN1ScviEv:
106 // CHECK-LP64: callq __ZN1Ycv1ZEv
107 // CHECK-LP64: callq __ZN1Zcv1XEv
108 // CHECK-LP64: callq __ZN1XcviEv
109 // CHECK-LP64: callq __ZN1XcvfEv
110 // CHECK-LP64: callq __ZN2XBcviEv
111 // CHECK-LP64: callq __ZN2YbcvcEv
113 // CHECK-LP32: .globl __ZN1ScviEv
114 // CHECK-LP32-NEXT: __ZN1ScviEv:
115 // CHECK-LP32: call L__ZN1Ycv1ZEv
116 // CHECK-LP32: call L__ZN1Zcv1XEv
117 // CHECK-LP32: call L__ZN1XcviEv
118 // CHECK-LP32: call L__ZN1XcvfEv
119 // CHECK-LP32: call L__ZN2XBcviEv
120 // CHECK-LP32: call L__ZN2YbcvcEv