[clang] trigger -Wcast-qual on functional casts
authorJorge Pinto Sousa <jorge.pinto.sousa@proton.me>
Fri, 21 Apr 2023 11:45:05 +0000 (07:45 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 21 Apr 2023 11:45:05 +0000 (07:45 -0400)
commit7c0021923503a9a5fe1ba1f0b778b5b83c42aa43
tree90568bbb54b37bb932a99f6bdc51adcc478254c3
parent5368c1065f0eaefc442247134ba3b2e98c97fda7
[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
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaCast.cpp
clang/test/SemaCXX/warn-cast-qual.cpp