1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s 2 3 struct Base1 { 4 virtual void g(); 5 }; 6 7 struct A : Base1 { 8 virtual void g() override override; // expected-error {{class member already marked 'override'}} 9 virtual void h() final final; // expected-error {{class member already marked 'final'}} 10 }; 11 12 struct Base2 { 13 virtual void e1(), e2(); 14 virtual void f(); 15 }; 16 17 struct B : Base2 { 18 virtual void e1() override, e2(int); // No error. 19 virtual void f() override; 20 void g() override; // expected-error {{only virtual member functions can be marked 'override'}} 21 int h override; // expected-error {{only virtual member functions can be marked 'override'}} 22 }; 23 24 struct C { 25 virtual void f() final; 26 void g() final; // expected-error {{only virtual member functions can be marked 'final'}} 27 int h final; // expected-error {{only virtual member functions can be marked 'final'}} 28 }; 29 30 namespace inline_extension { 31 struct Base1 { ginline_extension::Base132 virtual void g() {} 33 }; 34 35 struct A : Base1 { ginline_extension::A36 virtual void g() override override {} // expected-error {{class member already marked 'override'}} hinline_extension::A37 virtual void h() final final {} // expected-error {{class member already marked 'final'}} 38 }; 39 40 struct Base2 { 41 virtual void f(); 42 }; 43 44 struct B : Base2 { finline_extension::B45 virtual void f() override {} ginline_extension::B46 void g() override {} // expected-error {{only virtual member functions can be marked 'override'}} 47 }; 48 49 struct C { finline_extension::C50 virtual void f() final {} ginline_extension::C51 void g() final {} // expected-error {{only virtual member functions can be marked 'final'}} 52 }; 53 } 54