1 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
3 // Multiple inheritance is involved (code segmments all disagree between the bases and derived class)
4 struct __declspec(code_seg("my_base")) Base1
{};
7 struct D1
: Base1
, Base2
{};
8 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
9 // expected-note@4 {{base class 'Base1' specified here}}
11 struct __declspec(code_seg("my_derived")) D2
: Base2
, Base1
{};
12 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
13 // expected-error@-2 {{derived class must specify the same code segment as its base classes}}
14 // expected-note@5 {{base class 'Base2' specified here}}
15 // expected-note@4 {{base class 'Base1' specified here}}
17 // Multiple inheritance (code segments partially agree between the bases and the derived class)
18 struct __declspec(code_seg("base_class")) BaseClass1
{};
19 struct __declspec(code_seg("base_class")) BaseClass2
{};
21 struct Derived1
: BaseClass1
, BaseClass2
{};
22 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
23 // expected-error@-2 {{derived class must specify the same code segment as its base classes}}
24 // expected-note@18 {{base class 'BaseClass1' specified here}}
25 // expected-note@19 {{base class 'BaseClass2' specified here}}
27 struct __declspec(code_seg("derived_class")) Derived2
: BaseClass2
, BaseClass1
{};
28 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
29 // expected-error@-2 {{derived class must specify the same code segment as its base classes}}
30 // expected-note@19 {{base class 'BaseClass2' specified here}}
31 // expected-note@18 {{base class 'BaseClass1' specified here}}
33 struct __declspec(code_seg("base_class")) Derived3
: BaseClass2
, BaseClass1
{}; //OK
34 struct __declspec(code_seg("base_class")) Derived4
: BaseClass1
, BaseClass2
{}; //OK
36 // Multiple inheritance is involved (code segmments all agree between the bases and derived class)
37 struct __declspec(code_seg("foo_base")) B1
{};
38 struct __declspec(code_seg("foo_base")) B2
{};
39 struct __declspec(code_seg("foo_base")) Derived
: B1
, B2
{};
41 // virtual Inheritance is involved (code segmments all disagree between the bases and derived class)
42 struct __declspec(code_seg("my_one")) Base
{
43 virtual int barA() { return 1; } ;
46 struct __declspec(code_seg("my_two")) Derived5
: virtual Base
{
47 virtual int barB() { return 2; };
49 // expected-error@-3 {{derived class must specify the same code segment as its base classes}}
50 // expected-note@42 {{base class 'Base' specified here}}
52 struct __declspec(code_seg("my_three")) Derived6
: virtual Base
{
53 virtual int barC() { return 3; };
55 // expected-error@-3 {{derived class must specify the same code segment as its base classes}}
56 // expected-note@42 {{base class 'Base' specified here}}
58 struct __declspec(code_seg("my_four")) Derived7
: Derived5
, Derived6
{};
59 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
60 // expected-error@-2 {{derived class must specify the same code segment as its base classes}}
61 // expected-note@46 {{base class 'Derived5' specified here}}
62 // expected-note@52 {{base class 'Derived6' specified here}}
64 // virtual Inheritance is involved (code segmments partially agree between the bases and derived class)
65 struct __declspec(code_seg("my_class")) BaseClass
{
66 virtual int barA() { return 1; } ;
69 struct __declspec(code_seg("my_class")) DerivedClass1
: virtual BaseClass
{ //OK
70 virtual int barB() { return 2; };
73 struct __declspec(code_seg("my_class")) DerivedClass2
: virtual BaseClass
{ //OK
74 virtual int barC() { return 3; };
77 struct __declspec(code_seg("my_derived_one")) DerivedClass3
: DerivedClass1
, DerivedClass2
{};
78 // expected-error@-1 {{derived class must specify the same code segment as its base classes}}
79 // expected-error@-2 {{derived class must specify the same code segment as its base classes}}
80 // expected-note@69 {{base class 'DerivedClass1' specified here}}
81 // expected-note@73 {{base class 'DerivedClass2' specified here}}
83 // virtual Inheritance is involved (code segmments all agree between the bases and derived class)
84 struct __declspec(code_seg("foo_one")) Class
{
85 virtual int foo1() { return 10; } ;
88 struct __declspec(code_seg("foo_one")) Derived_One
: virtual Class
{ //OK
89 virtual int foo2() { return 20; };
92 struct __declspec(code_seg("foo_one")) Derived_Two
: virtual Class
{ //OK
93 virtual int foo3() { return 30; };
96 struct __declspec(code_seg("foo_one")) Derived_Three
: Derived_One
, Derived_Two
{}; //OK