[clang] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes (PR #121419)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 14:52:00 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 {
----------------
a-tarasyuk wrote:
@erichkeane Thanks for the feedback. I've added additional tests, excluding the case `struct E : const T {};`, since `const` can't be used here
https://github.com/llvm/llvm-project/pull/121419
More information about the cfe-commits
mailing list