[clang] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes (PR #121419)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 07:30:19 PST 2025
================
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify
+
+class A { };
+
+typedef const A A_Const;
+class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') have no effect}} \
+ // expected-note {{base class 'A_Const' (aka 'const A') specified here}}
+
+typedef const volatile A A_Const_Volatile;
+class C : public A_Const_Volatile { }; // expected-warning {{'const volatile' qualifiers on base class type 'A_Const_Volatile' (aka 'const volatile A') have no effect}} \
+ // expected-note {{base class 'A_Const_Volatile' (aka 'const volatile A') specified here}}
+
+struct D {
+ D(int);
+};
+template <typename T> struct E : T {
----------------
erichkeane wrote:
I would like us to, at least at first? Is the diagnostic reasonable?
My fear of course is that this ends up being SUPER noisy here in the template case, but I would like to get feedback on this. We could potentially split the template-case into a separate diagnostic group to make it easier to suppress.
That said, your current cutout for this is likely insufficient. What if this was: `struct E : T::type` where that has a const on it?
https://github.com/llvm/llvm-project/pull/121419
More information about the cfe-commits
mailing list