blob: 6a02a86731865b267c564e626d3b0f37412e70f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// 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<typename T>
struct B : A {
// FIXME: Diagnose this.
virtual void f(T) override;
};
template<typename T>
struct C : A {
virtual void f(int) override; // expected-error {{does not override}}
};
}
namespace Test3 {
struct A {
virtual void f(int, char, int);
};
template<typename... Args>
struct B : A {
virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}}
};
template struct B<int, char, int>;
template struct B<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' 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<typename T> struct A : X {
void f() override;
void h() final;
};
template<typename T> 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<int> b; // no-note
template<typename T> struct C : T {
void g() override;
void i() final;
};
template<typename T> struct D : X {
virtual void g() override; // expected-error {{does not override}}
virtual void i() final;
};
template<typename...T> 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<typename T> struct Y : T {
void f() override;
void h() final;
};
template<typename T> 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<X> y;
Z<X> z; // expected-note {{in instantiation of}}
}
namespace MemberOfUnknownSpecialization {
template<typename T> struct A {
struct B {};
struct C : B {
void f() override;
};
};
template<> struct A<int>::B {
virtual void f();
};
// ok
A<int>::C c1;
template<> struct A<char>::B {
void f();
};
// expected-error@-13 {{only virtual member functions can be marked 'override'}}
// expected-note@+1 {{in instantiation of}}
A<char>::C c2;
template<> struct A<double>::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<double>::C c3;
}
|