[clang] [clang] When checking for covariant return types, make sure the pointers or references are to *classes* (PR #111856)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 03:22:54 PDT 2024
================
@@ -289,3 +289,13 @@ namespace PR8168 {
static void foo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}}
};
}
+
+namespace T13 {
+ struct A {
+ virtual const int *f() const; // expected-note{{overridden virtual function is here}}
+ };
+
+ struct B : A {
+ int *f() const override; // expected-error{{virtual function 'f' has a different return type ('int *') than the function it overrides (which has return type 'const int *')}}
+ };
+}
----------------
ilya-biryukov wrote:
Given that the code has a different treatment of types which are pointers and references, having a variation of `T2` with non-class types seems valuable. (we could probably add it to `T2` directly).
Same for qualification in `T6`, given that the rules are special for the class types.
https://github.com/llvm/llvm-project/pull/111856
More information about the cfe-commits
mailing list