// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s namespace Test1 { struct B { virtual void f(int); }; struct D : B { virtual void f(long) override; // expected-error {{'f' marked 'override' but does not override any member functions}} void f(int) override; }; } namespace Test2 { struct A { virtual void f(int, char, int); }; template struct B : A { // FIXME: Diagnose this. virtual void f(T) override; }; template struct C : A { virtual void f(int) override; // expected-error {{does not override}} }; } namespace Test3 { struct A { virtual void f(int, char, int); }; template struct B : A { virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} }; template struct B; template struct B; // expected-note {{in instantiation of template class 'Test3::B' requested here}} } namespace Test4 { struct B { virtual void f() const final; // expected-note {{overridden virtual function is here}} }; struct D : B { void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}} }; } namespace PR13499 { struct X { virtual void f(); virtual void h(); }; template struct A : X { void f() override; void h() final; }; template struct B : X { void g() override; // expected-error {{only virtual member functions can be marked 'override'}} void i() final; // expected-error {{only virtual member functions can be marked 'final'}} }; B b; // no-note template struct C : T { void g() override; void i() final; }; template struct D : X { virtual void g() override; // expected-error {{does not override}} virtual void i() final; }; template struct E : X { void f(T...) override; void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} void h(T...) final; void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} }; // FIXME: Diagnose these in the template definition, not in the instantiation. E<> e; // expected-note {{in instantiation of}} template struct Y : T { void f() override; void h() final; }; template struct Z : T { void g() override; // expected-error {{only virtual member functions can be marked 'override'}} void i() final; // expected-error {{only virtual member functions can be marked 'final'}} }; Y y; Z z; // expected-note {{in instantiation of}} } namespace MemberOfUnknownSpecialization { template struct A { struct B {}; struct C : B { void f() override; }; }; template<> struct A::B { virtual void f(); }; // ok A::C c1; template<> struct A::B { void f(); }; // expected-error@-13 {{only virtual member functions can be marked 'override'}} // expected-note@+1 {{in instantiation of}} A::C c2; template<> struct A::B { virtual void f() final; }; // expected-error@-20 {{declaration of 'f' overrides a 'final' function}} // expected-note@-3 {{here}} // expected-note@+1 {{in instantiation of}} A::C c3; } namespace DiagnosticsQOI { struct X { virtual ~X(); virtual void foo(int x); // expected-note {{hidden overloaded virtual function}} virtual void bar(int x); // expected-note 2 {{hidden overloaded virtual function}} virtual void bar(float x); // expected-note 2 {{hidden overloaded virtual function}} }; struct Y : X { void foo(int x, int y) override; // expected-error {{non-virtual member function marked 'override' hides virtual member function}} void bar(double) override; // expected-error {{non-virtual member function marked 'override' hides virtual member functions}} void bar(long double) final; // expected-error {{non-virtual member function marked 'final' hides virtual member functions}} }; template struct Z : T { static void foo() override; // expected-error {{only virtual member functions can be marked 'override'}} }; }