Erich Keane | 7963e8b | 2018-07-18 20:04:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32 |
| 2 | // expected-no-diagnostics |
| 3 | |
| 4 | // Non-Member Function Overloading is involved |
| 5 | |
| 6 | int __declspec(code_seg("foo_one")) bar_one(int) { return 1; } |
| 7 | //CHECK: define {{.*}}bar_one{{.*}} section "foo_one" |
| 8 | int __declspec(code_seg("foo_two")) bar_one(int,float) { return 11; } |
| 9 | //CHECK: define {{.*}}bar_one{{.*}} section "foo_two" |
| 10 | int __declspec(code_seg("foo_three")) bar_one(float) { return 12; } |
| 11 | //CHECK: define {{.*}}bar_one{{.*}} section "foo_three" |
| 12 | |
| 13 | // virtual function overloading is involved |
| 14 | |
| 15 | struct __declspec(code_seg("my_one")) Base3 { |
| 16 | virtual int barA(int) { return 1; } |
| 17 | virtual int barA(int,float) { return 2; } |
| 18 | virtual int barA(float) { return 3; } |
| 19 | |
| 20 | virtual void __declspec(code_seg("my_two")) barB(int) { } |
| 21 | virtual void __declspec(code_seg("my_three")) barB(float) { } |
| 22 | virtual void __declspec(code_seg("my_four")) barB(int, float) { } |
| 23 | |
| 24 | }; |
| 25 | |
| 26 | //CHECK: define {{.*}}barA@Base3{{.*}} section "my_one" |
| 27 | //CHECK: define {{.*}}barA@Base3{{.*}} section "my_one" |
| 28 | //CHECK: define {{.*}}barA@Base3{{.*}} section "my_one" |
| 29 | //CHECK: define {{.*}}barB@Base3{{.*}} section "my_two" |
| 30 | //CHECK: define {{.*}}barB@Base3{{.*}} section "my_three" |
| 31 | //CHECK: define {{.*}}barB@Base3{{.*}} section "my_four" |
| 32 | |
| 33 | #pragma code_seg("another") |
| 34 | // Member functions |
| 35 | struct __declspec(code_seg("foo_four")) Foo { |
| 36 | int bar3() {return 0;} |
| 37 | __declspec(code_seg("foo_lala")) int bar4() {return 0;} }; int caller() {Foo f; return f.bar3() + f.bar4(); } |
| 38 | |
| 39 | //CHECK: define {{.*}}bar3@Foo{{.*}} section "foo_four" |
| 40 | //CHECK: define {{.*}}bar4@Foo{{.*}} section "foo_lala" |
| 41 | |
| 42 | // Lambdas |
| 43 | #pragma code_seg("something") |
| 44 | |
| 45 | int __declspec(code_seg("foo")) bar1() |
| 46 | { |
| 47 | int lala = 4; |
| 48 | auto l = [=](int i) { return i+4; }; |
| 49 | return l(-4); |
| 50 | } |
| 51 | |
| 52 | //CHECK: define {{.*}}bar1{{.*}} section "foo" |
| 53 | //CHECK: define {{.*}}lambda{{.*}}bar1{{.*}} section "something" |
| 54 | |
| 55 | double __declspec(code_seg("foo")) bar2() |
| 56 | { |
| 57 | double lala = 4.0; |
| 58 | auto l = [=](double d) __declspec(code_seg("another")) { return d+4.0; }; |
| 59 | return l(4.0); |
| 60 | } |
| 61 | |
| 62 | //CHECK: define {{.*}}bar2{{.*}} section "foo" |
| 63 | //CHECK: define {{.*}}lambda{{.*}}bar2{{.*}} section "another" |
| 64 | |
| 65 | |