You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang] Unify the new covariant tests, remove T13 and add the new tests into T2 and T6.
In T2, we check that return types that are pointers to different non-class types fail.
In T6, we check that unlike class return types, non-class return types do not allow to change qualifiers at all (add or remove).
Copy file name to clipboardExpand all lines: clang/test/SemaCXX/virtual-override.cpp
+6-10Lines changed: 6 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,12 @@ struct b { };
19
19
20
20
classA {
21
21
virtual a* f(); // expected-note{{overridden virtual function is here}}
22
+
virtualint *g(); // expected-note{{overridden virtual function is here}}
22
23
};
23
24
24
25
classB : A {
25
26
virtual b* f(); // expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('b *' is not derived from 'a *')}}
27
+
virtualchar *g(); // expected-error{{virtual function 'g' has a different return type ('char *') than the function it overrides (which has return type 'int *')}}
26
28
};
27
29
28
30
}
@@ -83,11 +85,15 @@ struct a { };
83
85
classA {
84
86
virtualconst a* f();
85
87
virtual a* g(); // expected-note{{overridden virtual function is here}}
88
+
virtualconstint* h(); // expected-note{{overridden virtual function is here}}
89
+
virtualint* i(); // expected-note{{overridden virtual function is here}}
86
90
};
87
91
88
92
classB : A {
89
93
virtual a* f();
90
94
virtualconst a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const a *' is more qualified than class type 'a *'}}
95
+
virtualint* h(); // expected-error{{virtual function 'h' has a different return type ('int *') than the function it overrides (which has return type 'const int *')}}
96
+
virtualconstint* i(); // expected-error{{virtual function 'i' has a different return type ('const int *') than the function it overrides (which has return type 'int *')}}
91
97
};
92
98
93
99
}
@@ -289,13 +295,3 @@ namespace PR8168 {
289
295
staticvoidfoo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}}
290
296
};
291
297
}
292
-
293
-
namespaceT13 {
294
-
structA {
295
-
virtualconstint *f() const; // expected-note{{overridden virtual function is here}}
296
-
};
297
-
298
-
structB : A {
299
-
int *f() constoverride; // expected-error{{virtual function 'f' has a different return type ('int *') than the function it overrides (which has return type 'const int *')}}
0 commit comments