1*7963e8beSErich Keane // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32 2*7963e8beSErich Keane 3*7963e8beSErich Keane // Multiple inheritance is involved (code segmments all disagree between the bases and derived class) 4*7963e8beSErich Keane struct __declspec(code_seg("my_base")) Base1 {}; 5*7963e8beSErich Keane struct Base2 {}; 6*7963e8beSErich Keane 7*7963e8beSErich Keane struct D1 : Base1, Base2 {}; 8*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 9*7963e8beSErich Keane // expected-note@4 {{base class 'Base1' specified here}} 10*7963e8beSErich Keane 11*7963e8beSErich Keane struct __declspec(code_seg("my_derived")) D2 : Base2, Base1 {}; 12*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 13*7963e8beSErich Keane // expected-error@-2 {{derived class must specify the same code segment as its base classes}} 14*7963e8beSErich Keane // expected-note@5 {{base class 'Base2' specified here}} 15*7963e8beSErich Keane // expected-note@4 {{base class 'Base1' specified here}} 16*7963e8beSErich Keane 17*7963e8beSErich Keane // Multiple inheritance (code segments partially agree between the bases and the derived class) 18*7963e8beSErich Keane struct __declspec(code_seg("base_class")) BaseClass1 {}; 19*7963e8beSErich Keane struct __declspec(code_seg("base_class")) BaseClass2 {}; 20*7963e8beSErich Keane 21*7963e8beSErich Keane struct Derived1 : BaseClass1, BaseClass2 {}; 22*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 23*7963e8beSErich Keane // expected-error@-2 {{derived class must specify the same code segment as its base classes}} 24*7963e8beSErich Keane // expected-note@18 {{base class 'BaseClass1' specified here}} 25*7963e8beSErich Keane // expected-note@19 {{base class 'BaseClass2' specified here}} 26*7963e8beSErich Keane 27*7963e8beSErich Keane struct __declspec(code_seg("derived_class")) Derived2 : BaseClass2, BaseClass1 {}; 28*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 29*7963e8beSErich Keane // expected-error@-2 {{derived class must specify the same code segment as its base classes}} 30*7963e8beSErich Keane // expected-note@19 {{base class 'BaseClass2' specified here}} 31*7963e8beSErich Keane // expected-note@18 {{base class 'BaseClass1' specified here}} 32*7963e8beSErich Keane 33*7963e8beSErich Keane struct __declspec(code_seg("base_class")) Derived3 : BaseClass2, BaseClass1 {}; //OK 34*7963e8beSErich Keane struct __declspec(code_seg("base_class")) Derived4 : BaseClass1, BaseClass2 {}; //OK 35*7963e8beSErich Keane 36*7963e8beSErich Keane // Multiple inheritance is involved (code segmments all agree between the bases and derived class) 37*7963e8beSErich Keane struct __declspec(code_seg("foo_base")) B1 {}; 38*7963e8beSErich Keane struct __declspec(code_seg("foo_base")) B2 {}; 39*7963e8beSErich Keane struct __declspec(code_seg("foo_base")) Derived : B1, B2 {}; 40*7963e8beSErich Keane 41*7963e8beSErich Keane // virtual Inheritance is involved (code segmments all disagree between the bases and derived class) 42*7963e8beSErich Keane struct __declspec(code_seg("my_one")) Base { barABase43*7963e8beSErich Keane virtual int barA() { return 1; } ; 44*7963e8beSErich Keane }; 45*7963e8beSErich Keane 46*7963e8beSErich Keane struct __declspec(code_seg("my_two")) Derived5 : virtual Base { barBDerived547*7963e8beSErich Keane virtual int barB() { return 2; }; 48*7963e8beSErich Keane }; 49*7963e8beSErich Keane // expected-error@-3 {{derived class must specify the same code segment as its base classes}} 50*7963e8beSErich Keane // expected-note@42 {{base class 'Base' specified here}} 51*7963e8beSErich Keane 52*7963e8beSErich Keane struct __declspec(code_seg("my_three")) Derived6 : virtual Base { barCDerived653*7963e8beSErich Keane virtual int barC() { return 3; }; 54*7963e8beSErich Keane }; 55*7963e8beSErich Keane // expected-error@-3 {{derived class must specify the same code segment as its base classes}} 56*7963e8beSErich Keane // expected-note@42 {{base class 'Base' specified here}} 57*7963e8beSErich Keane 58*7963e8beSErich Keane struct __declspec(code_seg("my_four")) Derived7 : Derived5, Derived6 {}; 59*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 60*7963e8beSErich Keane // expected-error@-2 {{derived class must specify the same code segment as its base classes}} 61*7963e8beSErich Keane // expected-note@46 {{base class 'Derived5' specified here}} 62*7963e8beSErich Keane // expected-note@52 {{base class 'Derived6' specified here}} 63*7963e8beSErich Keane 64*7963e8beSErich Keane // virtual Inheritance is involved (code segmments partially agree between the bases and derived class) 65*7963e8beSErich Keane struct __declspec(code_seg("my_class")) BaseClass { barABaseClass66*7963e8beSErich Keane virtual int barA() { return 1; } ; 67*7963e8beSErich Keane }; 68*7963e8beSErich Keane 69*7963e8beSErich Keane struct __declspec(code_seg("my_class")) DerivedClass1 : virtual BaseClass { //OK barBDerivedClass170*7963e8beSErich Keane virtual int barB() { return 2; }; 71*7963e8beSErich Keane }; 72*7963e8beSErich Keane 73*7963e8beSErich Keane struct __declspec(code_seg("my_class")) DerivedClass2 : virtual BaseClass { //OK barCDerivedClass274*7963e8beSErich Keane virtual int barC() { return 3; }; 75*7963e8beSErich Keane }; 76*7963e8beSErich Keane 77*7963e8beSErich Keane struct __declspec(code_seg("my_derived_one")) DerivedClass3 : DerivedClass1, DerivedClass2 {}; 78*7963e8beSErich Keane // expected-error@-1 {{derived class must specify the same code segment as its base classes}} 79*7963e8beSErich Keane // expected-error@-2 {{derived class must specify the same code segment as its base classes}} 80*7963e8beSErich Keane // expected-note@69 {{base class 'DerivedClass1' specified here}} 81*7963e8beSErich Keane // expected-note@73 {{base class 'DerivedClass2' specified here}} 82*7963e8beSErich Keane 83*7963e8beSErich Keane // virtual Inheritance is involved (code segmments all agree between the bases and derived class) 84*7963e8beSErich Keane struct __declspec(code_seg("foo_one")) Class { foo1Class85*7963e8beSErich Keane virtual int foo1() { return 10; } ; 86*7963e8beSErich Keane }; 87*7963e8beSErich Keane 88*7963e8beSErich Keane struct __declspec(code_seg("foo_one")) Derived_One: virtual Class { //OK foo2Derived_One89*7963e8beSErich Keane virtual int foo2() { return 20; }; 90*7963e8beSErich Keane }; 91*7963e8beSErich Keane 92*7963e8beSErich Keane struct __declspec(code_seg("foo_one")) Derived_Two : virtual Class { //OK foo3Derived_Two93*7963e8beSErich Keane virtual int foo3() { return 30; }; 94*7963e8beSErich Keane }; 95*7963e8beSErich Keane 96*7963e8beSErich Keane struct __declspec(code_seg("foo_one")) Derived_Three : Derived_One, Derived_Two {}; //OK 97*7963e8beSErich Keane 98