Galina Kistanova | 0ccb31c | 2011-06-03 22:24:54 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-registered-target,x86-64-registered-target |
Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 3 | // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s |
Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 5 | // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 6 | |
| 7 | extern "C" int printf(...); |
| 8 | |
| 9 | class X { // ... |
| 10 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 11 | X(int) : iX(2), fX(2.3) , name("HELLO\n") { } |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 12 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 13 | 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 Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | void g(X arg) { |
| 24 | arg.pr(); |
| 25 | } |
| 26 | |
| 27 | void f(X arg) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 28 | X a = 1; // a = X(1) |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 29 | |
| 30 | a.pr(); |
| 31 | |
| 32 | X b = "Jessie"; // b=X("Jessie",0) |
| 33 | |
| 34 | b.pr(); |
| 35 | |
| 36 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 37 | a = 2; // a = X(2) |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 38 | |
| 39 | a.pr(); |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 43 | int main() { |
| 44 | X x; |
| 45 | f(x); |
| 46 | g(3); // g(X(3)) |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Sean Callanan | 3b29901 | 2009-12-18 00:04:09 +0000 | [diff] [blame] | 49 | // CHECK-LP64: callq __ZN1XC1Ei |
| 50 | // CHECK-LP64: callq __ZN1XC1EPKci |
| 51 | // CHECK-LP64: callq __ZN1XC1Ev |
Fariborz Jahanian | 7fe5d72 | 2009-08-28 22:04:50 +0000 | [diff] [blame] | 52 | |
Chris Lattner | 398e6b9 | 2010-09-22 06:09:31 +0000 | [diff] [blame] | 53 | // CHECK-LP32: calll L__ZN1XC1Ei |
| 54 | // CHECK-LP32: calll L__ZN1XC1EPKci |
| 55 | // CHECK-LP32: calll L__ZN1XC1Ev |