1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
10 virtual void f(long) override
; // expected-error {{'f' marked 'override' but does not override any member functions}}
18 virtual void f(int, char, int);
23 // FIXME: Diagnose this.
24 virtual void f(T
) override
;
29 virtual void f(int) override
; // expected-error {{does not override}}
37 virtual void f(int, char, int);
40 template<typename
... Args
>
42 virtual void f(Args
...) override
; // expected-error {{'f' marked 'override' but does not override any member functions}}
45 template struct B
<int, char, int>;
46 template struct B
<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' requested here}}
52 virtual void f() const final
; // expected-note {{overridden virtual function is here}}
56 void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}}
66 template<typename T
> struct A
: X
{
70 template<typename T
> struct B
: X
{
71 void g() override
; // expected-error {{only virtual member functions can be marked 'override'}}
72 void i() final
; // expected-error {{only virtual member functions can be marked 'final'}}
75 template<typename T
> struct C
: T
{
79 template<typename T
> struct D
: X
{
80 virtual void g() override
; // expected-error {{does not override}}
81 virtual void i() final
;
83 template<typename
...T
> struct E
: X
{
84 void f(T
...) override
;
85 void g(T
...) override
; // expected-error {{only virtual member functions can be marked 'override'}}
87 void i(T
...) final
; // expected-error {{only virtual member functions can be marked 'final'}}
89 // FIXME: Diagnose these in the template definition, not in the instantiation.
90 E
<> e
; // expected-note {{in instantiation of}}
92 template<typename T
> struct Y
: T
{
96 template<typename T
> struct Z
: T
{
97 void g() override
; // expected-error {{only virtual member functions can be marked 'override'}}
98 void i() final
; // expected-error {{only virtual member functions can be marked 'final'}}
101 Z
<X
> z
; // expected-note {{in instantiation of}}
104 namespace MemberOfUnknownSpecialization
{
105 template<typename T
> struct A
{
112 template<> struct A
<int>::B
{
118 template<> struct A
<char>::B
{
121 // expected-error@-13 {{only virtual member functions can be marked 'override'}}
122 // expected-note@+1 {{in instantiation of}}
125 template<> struct A
<double>::B
{
126 virtual void f() final
;
128 // expected-error@-20 {{declaration of 'f' overrides a 'final' function}}
129 // expected-note@-3 {{here}}
130 // expected-note@+1 {{in instantiation of}}
134 namespace DiagnosticsQOI
{
137 virtual void foo(int x
); // expected-note {{hidden overloaded virtual function}}
138 virtual void bar(int x
); // expected-note 2 {{hidden overloaded virtual function}}
139 virtual void bar(float x
); // expected-note 2 {{hidden overloaded virtual function}}
143 void foo(int x
, int y
) override
; // expected-error {{non-virtual member function marked 'override' hides virtual member function}}
144 void bar(double) override
; // expected-error {{non-virtual member function marked 'override' hides virtual member functions}}
145 void bar(long double) final
; // expected-error {{non-virtual member function marked 'final' hides virtual member functions}}
150 static void foo() override
; // expected-error {{only virtual member functions can be marked 'override'}}