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

Conversation

a-tarasyuk
Copy link
Member

Fixes #125942

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

Changes

Fixes #125942


Full diff: https://github.com/llvm/llvm-project/pull/125943.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1)
  • (modified) clang/test/SemaCXX/warn-base-type-qualifiers.cpp (+3-3)
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7b3b932c482baa..bcae9e9f300938 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp
index b9fd577c574b99..7c775a552dd886 100644
--- a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp
+++ b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp
@@ -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;
@@ -19,7 +19,7 @@ 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) {}
@@ -27,7 +27,7 @@ template <typename T> struct E : T { // expected-warning {{'const' qualifier on
 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) {}

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please improve the commit message to better explain what is going on, else LGTM.

@a-tarasyuk a-tarasyuk changed the title [Clang] refine diagnostic for redundant qualifiers on base class type to handle singular and plural cases [Clang] fix diagnostic to correctly handle singular and plural cases for redundant qualifiers on base class type Feb 5, 2025
@a-tarasyuk
Copy link
Member Author

@erichkeane thanks. I've changed the title/commit message.

@a-tarasyuk a-tarasyuk merged commit c7dc836 into llvm:main Feb 6, 2025
8 checks passed
@erichkeane
Copy link
Collaborator

erichkeane commented Feb 6, 2025

@erichkeane thanks. I've changed the title/commit message.

You did not unfortunately, so the commit has just:

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

Fixes https://github.com/llvm/llvm-project/issues/125942

PLEASE next time make sure the description of the PR (and thus the final commit message) describes the problem, and what you're doing to solve it.

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ungrammatical warning message "const qualifier have no effect"
3 participants