1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o - %s | FileCheck %s
2 // expected-no-diagnostics
6 int __declspec(code_seg("foo_one")) bar_one() { return 1; }
7 //CHECK: define {{.*}}bar_one{{.*}} section "foo_one"
9 // Simple case - explicit attribute used over pragma
10 #pragma code_seg("foo_two")
11 int __declspec(code_seg("foo_three")) bar2() { return 2; }
12 //CHECK: define {{.*}}bar2{{.*}} section "foo_three"
14 // Check that attribute on one function doesn't affect another
15 int another1() { return 1001; }
16 //CHECK: define {{.*}}another1{{.*}} section "foo_two"
20 struct __declspec(code_seg("foo_four")) Foo
{
21 int bar3() {return 0;}
23 int __declspec(code_seg("foo_six")) bar6() { return 6; }
24 int bar7() { return 7; }
26 int bar5() { return 5; }
28 virtual int baz1() { return 1; }
31 struct __declspec(code_seg("foo_four")) FooTwo
: Foo
{
32 int baz1() { return 20; }
36 Foo f
; return f
.bar3();
39 //CHECK: define {{.*}}bar3@Foo{{.*}} section "foo_four"
40 int Foo::bar4() { return 4; }
41 //CHECK: define {{.*}}bar4@Foo{{.*}} section "foo_four"
43 #pragma code_seg("someother")
48 return f
.z
.bar5() + f
.bar6() + f
.bar7() + fp
->baz1();
50 // MS Compiler and Docs do not match for nested routines
51 // Doc says: define {{.*}}bar5@Inner@Foo{{.*}} section "foo_four"
52 // Compiler says: define {{.*}}bar5@Inner@Foo{{.*}} section "foo_two"
53 // A bug has been reported: see https://reviews.llvm.org/D22931, the
54 // Microsoft feedback page is no longer available.
55 //CHECK: define {{.*}}bar5@Inner@Foo{{.*}} section "foo_two"
56 //CHECK: define {{.*}}bar6@Foo{{.*}} section "foo_six"
57 //CHECK: define {{.*}}bar7@Foo{{.*}} section "foo_four"
58 // Check that code_seg active at class declaration is not used on member
59 // declared outside class when it is not active.
61 #pragma code_seg(push,"AnotherSeg")
65 int bar9() { return 9; }
71 int FooThree::bar8() {return 0;}
76 return f
.bar8() + f
.bar9();
79 //CHECK: define {{.*}}bar8@FooThree{{.*}} section "someother"
80 //CHECK: define {{.*}}bar9@FooThree{{.*}} section "AnotherSeg"
82 struct NonTrivialCopy
{
84 NonTrivialCopy(const NonTrivialCopy
&);
88 // check the section for compiler-generated function with declspec.
90 struct __declspec(code_seg("foo_seven")) FooFour
{
92 int __declspec(code_seg("foo_eight")) bar10(int t
) { return t
; }
96 //CHECK: define {{.*}}0FooFour@@QAE@ABU0@@Z{{.*}} section "foo_seven"
97 // check the section for compiler-generated function with no declspec.
101 int __declspec(code_seg("foo_nine")) bar11(int t
) { return t
; }
105 //CHECK: define {{.*}}0FooFive@@QAE@ABU0@@Z{{.*}} section "someother"
107 #pragma code_seg("YetAnother")
114 return z2
.bar10(0) + y2
.bar11(1);
117 //CHECK: define {{.*}}bar10@FooFour{{.*}} section "foo_eight"
118 //CHECK: define {{.*}}bar11@FooFive{{.*}} section "foo_nine"
121 #pragma code_seg("foo_ten")
122 int bar12() { return 12; }
123 #pragma code_seg("foo_eleven")
124 int bar13() { return 13; }
127 int bar14() { return 14; }
128 //CHECK: define {{.*}}bar14{{.*}} section "foo_eleven"
133 return fsix
.bar12() + fsix
.bar13();
136 //CHECK: define {{.*}}bar12@FooSix{{.*}} section "foo_ten"
137 //CHECK: define {{.*}}bar13@FooSix{{.*}} section "foo_eleven"
138 //CHECK: define {{.*}}baz1@FooTwo{{.*}} section "foo_four"