[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:
Can I also have a test for something like:
`struct E : const T`, or `struct E : add_const_t<T>`?
https://github.com/llvm/llvm-project/pull/121419
More information about the cfe-commits
mailing list