xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/constructor-conversion.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \
2*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \
4*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc extern "C" int printf(...);
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc class X { // ...
9f4a2713aSLionel Sambuc public:
X(int)10f4a2713aSLionel Sambuc   X(int) : iX(2), fX(2.3) , name("HELLO\n") {  }
11f4a2713aSLionel Sambuc 
X(const char * arg,int ix=0)12f4a2713aSLionel Sambuc   X(const char* arg, int ix=0) { iX = ix; fX = 6.0; name = arg+ix; }
X()13f4a2713aSLionel Sambuc   X(): iX(100), fX(1.2) {}
14f4a2713aSLionel Sambuc   int iX;
15f4a2713aSLionel Sambuc   float fX;
16f4a2713aSLionel Sambuc   const char *name;
pr(void)17f4a2713aSLionel Sambuc   void pr(void) {
18f4a2713aSLionel Sambuc     printf("iX = %d  fX = %f name = %s\n", iX, fX, name);
19f4a2713aSLionel Sambuc   }
20f4a2713aSLionel Sambuc };
21f4a2713aSLionel Sambuc 
g(X arg)22f4a2713aSLionel Sambuc void g(X arg) {
23f4a2713aSLionel Sambuc   arg.pr();
24f4a2713aSLionel Sambuc }
25f4a2713aSLionel Sambuc 
f(X arg)26f4a2713aSLionel Sambuc void f(X arg) {
27f4a2713aSLionel Sambuc   X a = 1;        // a = X(1)
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc   a.pr();
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc   X b = "Jessie"; //  b=X("Jessie",0)
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc   b.pr();
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc   a = 2;          // a = X(2)
37f4a2713aSLionel Sambuc 
38f4a2713aSLionel Sambuc   a.pr();
39f4a2713aSLionel Sambuc }
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc 
main()42f4a2713aSLionel Sambuc int main() {
43f4a2713aSLionel Sambuc   X x;
44f4a2713aSLionel Sambuc   f(x);
45f4a2713aSLionel Sambuc   g(3);           // g(X(3))
46f4a2713aSLionel Sambuc }
47f4a2713aSLionel Sambuc 
48*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1XC1Ei
49*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1XC1EPKci
50*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1XC1Ev
51