[all-commits] [llvm/llvm-project] 7c0021: [clang] trigger -Wcast-qual on functional casts

Jorge Pinto Sousa via All-commits all-commits at lists.llvm.org
Fri Apr 21 04:46:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c0021923503a9a5fe1ba1f0b778b5b83c42aa43
      https://github.com/llvm/llvm-project/commit/7c0021923503a9a5fe1ba1f0b778b5b83c42aa43
  Author: Jorge Pinto Sousa <jorge.pinto.sousa at proton.me>
  Date:   2023-04-21 (Fri, 21 Apr 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaCast.cpp
    M clang/test/SemaCXX/warn-cast-qual.cpp

  Log Message:
  -----------
  [clang] trigger -Wcast-qual on functional casts

-Wcast-qual does not trigger on the following code in Clang, but does
in GCC.

const auto i = 42;
using T = int*;
auto p = T(&i);

The expected behavior is that a functional cast should trigger
the warning the same as the equivalent C cast because
the meaning is the same, and nothing about the functional cast
makes it easier to recognize that a const_cast is occurring.

Fixes https://github.com/llvm/llvm-project/issues/62083
Differential Revision: https://reviews.llvm.org/D148276




More information about the All-commits mailing list