Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
Anders Carlsson | 0a8f847 | 2009-09-16 15:53:40 +0000 | [diff] [blame] | 2 | |
Daniel Dunbar | ce9f423 | 2009-11-22 23:01:23 +0000 | [diff] [blame] | 3 | // Basic base class test. |
| 4 | struct f0_s0 { unsigned a; }; |
| 5 | struct f0_s1 : public f0_s0 { void *b; }; |
Chris Lattner | 9c254f0 | 2010-06-29 06:01:59 +0000 | [diff] [blame] | 6 | // CHECK: define void @_Z2f05f0_s1(i64 %a0.coerce0, i8* %a0.coerce1) |
Daniel Dunbar | ce9f423 | 2009-11-22 23:01:23 +0000 | [diff] [blame] | 7 | void f0(f0_s1 a0) { } |
| 8 | |
| 9 | // Check with two eight-bytes in base class. |
| 10 | struct f1_s0 { unsigned a; unsigned b; float c; }; |
| 11 | struct f1_s1 : public f1_s0 { float d;}; |
Chris Lattner | 225e286 | 2010-06-29 00:14:52 +0000 | [diff] [blame] | 12 | // CHECK: define void @_Z2f15f1_s1(i64 %a0.coerce0, double %a0.coerce1) |
Daniel Dunbar | ce9f423 | 2009-11-22 23:01:23 +0000 | [diff] [blame] | 13 | void f1(f1_s1 a0) { } |
| 14 | |
| 15 | // Check with two eight-bytes in base class and merge. |
| 16 | struct f2_s0 { unsigned a; unsigned b; float c; }; |
| 17 | struct f2_s1 : public f2_s0 { char d;}; |
Chris Lattner | 225e286 | 2010-06-29 00:14:52 +0000 | [diff] [blame] | 18 | // CHECK: define void @_Z2f25f2_s1(i64 %a0.coerce0, i64 %a0.coerce1) |
Daniel Dunbar | ce9f423 | 2009-11-22 23:01:23 +0000 | [diff] [blame] | 19 | void f2(f2_s1 a0) { } |
| 20 | |
Daniel Dunbar | 4971ff8 | 2009-12-22 01:19:25 +0000 | [diff] [blame] | 21 | // PR5831 |
Chris Lattner | 117e3f4 | 2010-07-30 04:02:24 +0000 | [diff] [blame] | 22 | // CHECK: define void @_Z2f34s3_1(i64 %x.coerce) |
Daniel Dunbar | 4971ff8 | 2009-12-22 01:19:25 +0000 | [diff] [blame] | 23 | struct s3_0 {}; |
| 24 | struct s3_1 { struct s3_0 a; long b; }; |
| 25 | void f3(struct s3_1 x) {} |
Daniel Dunbar | 67d438d | 2010-05-15 00:00:37 +0000 | [diff] [blame] | 26 | |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 27 | // CHECK: define i64 @_Z4f4_0M2s4i(i64 %a) |
Chris Lattner | 9c254f0 | 2010-06-29 06:01:59 +0000 | [diff] [blame] | 28 | // CHECK: define {{.*}} @_Z4f4_1M2s4FivE(i64 %a.coerce0, i64 %a.coerce1) |
Daniel Dunbar | 67d438d | 2010-05-15 00:00:37 +0000 | [diff] [blame] | 29 | struct s4 {}; |
| 30 | typedef int s4::* s4_mdp; |
| 31 | typedef int (s4::*s4_mfp)(); |
| 32 | s4_mdp f4_0(s4_mdp a) { return a; } |
| 33 | s4_mfp f4_1(s4_mfp a) { return a; } |
Chris Lattner | bcaedae | 2010-06-30 19:14:05 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | namespace PR7523 { |
| 37 | struct StringRef { |
| 38 | char *a; |
| 39 | }; |
| 40 | |
| 41 | void AddKeyword(StringRef, int x); |
| 42 | |
| 43 | void foo() { |
| 44 | // CHECK: define void @_ZN6PR75233fooEv() |
| 45 | // CHECK: call void @_ZN6PR752310AddKeywordENS_9StringRefEi(i8* {{.*}}, i32 4) |
| 46 | AddKeyword(StringRef(), 4); |
| 47 | } |
Chris Lattner | a7206c5 | 2010-07-29 17:04:54 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Chris Lattner | a7206c5 | 2010-07-29 17:04:54 +0000 | [diff] [blame] | 50 | namespace PR7742 { // Also rdar://8250764 |
| 51 | struct s2 { |
| 52 | float a[2]; |
| 53 | }; |
| 54 | |
| 55 | struct c2 : public s2 {}; |
| 56 | |
| 57 | // CHECK: define double @_ZN6PR77423fooEPNS_2c2E(%"struct.PR7742::c2"* %P) |
| 58 | c2 foo(c2 *P) { |
| 59 | } |
| 60 | |
Chris Lattner | 117e3f4 | 2010-07-30 04:02:24 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | namespace PR5179 { |
| 64 | struct B {}; |
| 65 | |
| 66 | struct B1 : B { |
| 67 | int* pa; |
| 68 | }; |
| 69 | |
| 70 | struct B2 : B { |
| 71 | B1 b1; |
| 72 | }; |
| 73 | |
| 74 | // CHECK: define i8* @_ZN6PR51793barENS_2B2E(i32* %b2.coerce) |
| 75 | const void *bar(B2 b2) { |
| 76 | return b2.b1.pa; |
| 77 | } |
| 78 | } |
Chris Lattner | b6c504b | 2010-08-23 05:26:13 +0000 | [diff] [blame^] | 79 | |
| 80 | namespace test5 { |
| 81 | struct Xbase { }; |
| 82 | struct Empty { }; |
| 83 | struct Y; |
| 84 | struct X : public Xbase { |
| 85 | Empty empty; |
| 86 | Y f(); |
| 87 | }; |
| 88 | struct Y : public X { |
| 89 | Empty empty; |
| 90 | }; |
| 91 | X getX(); |
| 92 | int takeY(const Y&, int y); |
| 93 | void g() { |
| 94 | // rdar://8340348 - The temporary for the X object needs to have a defined |
| 95 | // address when passed into X::f as 'this'. |
| 96 | takeY(getX().f(), 42); |
| 97 | } |
| 98 | // CHECK: void @_ZN5test51gEv() |
| 99 | // CHECK: alloca %"struct.test5::Y" |
| 100 | // CHECK: alloca %"struct.test5::X" |
| 101 | // CHECK: alloca %"struct.test5::Y" |
| 102 | } |