[clang] [Clang] add emit -Wignored-cv-qualifiers diagnostic for cv-qualified base classes (PR #132116)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 20 09:08:54 PDT 2025
MagentaTreehouse wrote:
> The more I think about it, the more I think that we should modify the warning to only happen on EXPLICIT qualifiers. So:
>
> ```
> struct Base{};
> using CBase = const Base;
>
> struct D1 : const Base {}; // DOES warn
> struct D2 : CBase{}; // a DIFFERENT warning (same wording perhaps?) under a different group.
> template<typename T> Templ: const T{};
> Templ<Base> t; // Causes same warning as D1.
> template<typename T> Templ2 : T{};
> Templ2<CBase> t; // Causes same warning as D2.
> ```
Adding qualifiers directly in base specifiers is invalid (and all major compilers correctly reject this). See grammar in [[class.derived.general]/1](https://timsong-cpp.github.io/cppwp/n4950/class.derived#general-1). Qualifiers can indirectly come from `decltype`, template parameters, type aliases and so on.
https://github.com/llvm/llvm-project/pull/132116
More information about the cfe-commits
mailing list