[all-commits] [llvm/llvm-project] 8f25c0: [clang] Fix covariant cv-qualification check to re...

Boaz Brickner via All-commits all-commits at lists.llvm.org
Thu Oct 17 07:51:08 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f25c0bc7d59a65f27faa88d7debc47275a3a3da
      https://github.com/llvm/llvm-project/commit/8f25c0bc7d59a65f27faa88d7debc47275a3a3da
  Author: Boaz Brickner <brickner at google.com>
  Date:   2024-10-17 (Thu, 17 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/test/SemaCXX/virtual-override.cpp

  Log Message:
  -----------
  [clang] Fix covariant cv-qualification check to require the override function return type to have the same or less cv-qualification (#112713)

This prevents changing cv-qualification from const to volatile or vice
versa, for example.

https://eel.is/c++draft/class.virtual#8.3

Previously, we checked that the new type is the same or more qualified
to return an error, but the standard requires the new type to be the
same or less qualified and since the cv-qualification is only partially
ordered, we cannot rely on a check on whether it is more qualified to
return an error. Now, we reversed the condition to check whether the old
is at least as qualified, and return an error if it is not.

Also, adjusted the error name and message to clarify the requirement and
added a missing closing parenthesis.

Added tests to cover different use cases for classes with different
qualifications and also refactored them to make them easier to follow:
1. Use override to make sure the function names actually match.
2. Named the function in a more descriptive way to clarify what each use
case is checking.

Fixes: #111742



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list