Skip to content

[Clang] fix diagnostic to correctly handle singular and plural cases for redundant qualifiers on base class type #125943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def warn_qual_return_type : Warning<
"'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">,
InGroup<IgnoredQualifiers>, DefaultIgnore;
def warn_qual_base_type : Warning<
"'%0' qualifier%s1 on base class type %2 have no effect">,
"'%0' qualifier%s1 on base class type %2 %plural{1:has|:have}1 no effect">,
InGroup<IgnoredQualifiers>, DefaultIgnore;

def warn_deprecated_redundant_constexpr_static_def : Warning<
Expand Down
6 changes: 3 additions & 3 deletions clang/test/SemaCXX/warn-base-type-qualifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template <typename T> using add_const_t = typename add_const<T>::type;
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}} \
class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') has no effect}} \
// expected-note {{base class 'A_Const' (aka 'const A') specified here}}

typedef const volatile A A_Const_Volatile;
Expand All @@ -19,15 +19,15 @@ struct D {
D(int);
};

template <typename T> struct E : T { // expected-warning {{'const' qualifier on base class type 'const D' have no effect}} \
template <typename T> struct E : T { // expected-warning {{'const' qualifier on base class type 'const D' has no effect}} \
// expected-note {{base class 'const D' specified here}}
using T::T;
E(int &) : E(0) {}
};
E<const D> e(1); // expected-note {{in instantiation of template class 'E<const D>' requested here}}

template <typename T>
struct G : add_const<T>::type { // expected-warning {{'const' qualifier on base class type 'add_const<D>::type' (aka 'const D') have no effect}} \
struct G : add_const<T>::type { // expected-warning {{'const' qualifier on base class type 'add_const<D>::type' (aka 'const D') has no effect}} \
// expected-note {{base class 'add_const<D>::type' (aka 'const D') specified here}}
using T::T;
G(int &) : G(0) {}
Expand Down