blob: 58d0d39c8107b391e02b68af4d9a4ca77ac27cda [file] [log] [blame]
Galina Kistanova0ccb31c2011-06-03 22:24:54 +00001// REQUIRES: x86-registered-target,x86-64-registered-target
Daniel Dunbara5728872009-12-15 20:14:24 +00002// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00003// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
Daniel Dunbara5728872009-12-15 20:14:24 +00004// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00005// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +00006
7extern "C" int printf(...);
8
9class X { // ...
10public:
Mike Stump1eb44332009-09-09 15:08:12 +000011 X(int) : iX(2), fX(2.3) , name("HELLO\n") { }
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000012
Mike Stump1eb44332009-09-09 15:08:12 +000013 X(const char* arg, int ix=0) { iX = ix; fX = 6.0; name = arg+ix; }
14 X(): iX(100), fX(1.2) {}
15 int iX;
16 float fX;
17 const char *name;
18 void pr(void) {
19 printf("iX = %d fX = %f name = %s\n", iX, fX, name);
20 }
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000021};
22
23void g(X arg) {
24 arg.pr();
25}
26
27void f(X arg) {
Mike Stump1eb44332009-09-09 15:08:12 +000028 X a = 1; // a = X(1)
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000029
30 a.pr();
31
32 X b = "Jessie"; // b=X("Jessie",0)
33
34 b.pr();
35
36
Mike Stump1eb44332009-09-09 15:08:12 +000037 a = 2; // a = X(2)
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000038
39 a.pr();
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000040}
41
42
Mike Stump1eb44332009-09-09 15:08:12 +000043int main() {
44 X x;
45 f(x);
46 g(3); // g(X(3))
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000047}
48
Sean Callanan3b299012009-12-18 00:04:09 +000049// CHECK-LP64: callq __ZN1XC1Ei
50// CHECK-LP64: callq __ZN1XC1EPKci
51// CHECK-LP64: callq __ZN1XC1Ev
Fariborz Jahanian7fe5d722009-08-28 22:04:50 +000052
Chris Lattner398e6b92010-09-22 06:09:31 +000053// CHECK-LP32: calll L__ZN1XC1Ei
54// CHECK-LP32: calll L__ZN1XC1EPKci
55// CHECK-LP32: calll L__ZN1XC1Ev