================
@@ -289,3 +289,29 @@ namespace PR8168 {
static void foo() {} // expected-error{{'static' member function 'foo'
overrides a virtual function}}
};
}
+
+namespace T13 {
+ class A {
+ public:
+ virtual const int* foo(); // expected-note{{overridden virtual function is
here}}
+ };
+
+ class B: public A {
+ public:
+ virtual int* foo(); // expected-error{{return type of virtual function
'foo' is not covariant with the return type of the function it overrides ('int
*' has different qualifiers than 'const int *')}}
+ };
+}
+
+namespace T14 {
+ struct a {};
+
+ class A {
+ public:
+ virtual const a* foo(); // expected-note{{overridden virtual function is
here}}
+ };
+
+ class B: public A {
+ public:
+ virtual volatile a* foo(); // expected-error{{return type of virtual
function 'foo' is not covariant with the return type of the function it
overrides (class type 'volatile a *' is more qualified than class type 'const a
*')}}
----------------
Fznamznon wrote:
I guess technically volatile is not more qualified than const
https://eel.is/c++draft/tab:basic.type.qualifier.rel, should we also emit `has
different qualifiers` phrase here instead?
https://github.com/llvm/llvm-project/pull/71696
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits