1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o - %s | FileCheck %s
2 // expected-no-diagnostics
3 // The Microsoft document says: "When this attribute is applied to a class,
4 // all member functions of the class and nested classes - this includes
5 // compiler-generated special member functions - are put in the specified segment."
6 // But the MS compiler does not always follow that. A bug has been reported:
7 // see https://reviews.llvm.org/D22931, the Microsoft feedback page is no
9 // The MS compiler will apply a declspec from the parent class if there is no
10 // #pragma code_seg active at the class definition. If there is an active
11 // code_seg that is used instead.
15 struct __declspec(code_seg("foo_outer")) Foo1
{
21 void Foo1::Inner::bar1() {}
22 void Foo1::Inner::bar2() {}
24 //CHECK: define {{.*}}bar1@Inner@Foo1{{.*}} section "foo_outer"
25 //CHECK: define {{.*}}bar2@Inner@Foo1{{.*}} section "foo_outer"
27 struct __declspec(code_seg("foo_outer")) Foo2
{
28 struct __declspec(code_seg("foo_inner")) Inner
{
33 void Foo2::Inner::bar1() {}
34 void Foo2::Inner::bar2() {}
36 //CHECK: define {{.*}}bar1@Inner@Foo2{{.*}} section "foo_inner"
37 //CHECK: define {{.*}}bar2@Inner@Foo2{{.*}} section "foo_inner"
39 #pragma code_seg(push, "otherseg")
40 struct __declspec(code_seg("foo_outer")) Foo3
{
46 void Foo3::Inner::bar1() {}
47 void Foo3::Inner::bar2() {}
49 //CHECK: define {{.*}}bar1@Inner@Foo3{{.*}} section "otherseg"
50 //CHECK: define {{.*}}bar2@Inner@Foo3{{.*}} section "otherseg"
52 struct __declspec(code_seg("foo_outer")) Foo4
{
53 struct __declspec(code_seg("foo_inner")) Inner
{
58 void Foo4::Inner::bar1() {}
59 void Foo4::Inner::bar2() {}
61 //CHECK: define {{.*}}bar1@Inner@Foo4{{.*}} section "foo_inner"
62 //CHECK: define {{.*}}bar2@Inner@Foo4{{.*}} section "foo_inner"
65 // Back to no active pragma
66 struct __declspec(code_seg("foo_outer")) Foo5
{
70 struct __declspec(code_seg("inner1_seg")) Inner1
{
78 void Foo5::Inner::bar1() {}
79 void Foo5::Inner::bar2() {}
80 void Foo5::Inner::Inner1::Inner2::bar1() {}
81 void Foo5::Inner::Inner1::Inner2::bar2() {}
83 //CHECK: define {{.*}}bar1@Inner@Foo5{{.*}} section "foo_outer"
84 //CHECK: define {{.*}}bar2@Inner@Foo5{{.*}} section "foo_outer"
85 //CHECK: define {{.*}}bar1@Inner2@Inner1@Inner@Foo5{{.*}} section "inner1_seg"
86 //CHECK: define {{.*}}bar2@Inner2@Inner1@Inner@Foo5{{.*}} section "inner1_seg"