[flang] [libcxx] [clang] [compiler-rt] [clang-tools-extra] [llvm] [Clang][Sema] Fix qualifier restriction of overriden methods (PR #71696)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 2 22:44:32 PST 2023


================
@@ -18469,9 +18469,22 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
 
 
   // The new class type must have the same or less qualifiers as the old type.
-  if (NewClassTy.isMoreQualifiedThan(OldClassTy)) {
+  if (!OldClassTy.isAtLeastAsQualifiedAs(NewClassTy)) {
----------------
shafik wrote:

In the comment right above we can add a standard reference see: https://eel.is/c++draft/class.virtual#8

e.g.

```cpp
// C++ [class.virtual]p8:
//   The return type of an overriding function shall be either identical to the return type of the overridden function or [covariant]
```

https://github.com/llvm/llvm-project/pull/71696


More information about the cfe-commits mailing list