Skip to content
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

warn on pointless qualifiers with fixit to remove them #9430

Open
llvmbot opened this issue Jan 26, 2011 · 4 comments
Open

warn on pointless qualifiers with fixit to remove them #9430

llvmbot opened this issue Jan 26, 2011 · 4 comments
Labels
bugzilla Issues migrated from bugzilla check-request Request for a new check in clang-tidy clang-tidy

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 26, 2011

Bugzilla Link 9058
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @chandlerc,@zmodem

Extended Description

We'd like a warning on the qualifier in code like:

  bool const f();
  void f(const int x);

with fixit to remove the dead qualifier. The one use case we want to not break is:

  void f(int *ptr);
  void f(int * const ptr) {
    *ptr++;  // the const prevents the typo "ptr++;"
  }

I'm proposing the warning name -Wpointless-qualifier.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Feb 8, 2011

Part of this is already -Wignored-qualifiers. We should finish off the cases it doesn't catch and add fixits.

In this testcase:

static const const int test1 = 10;
const int test2() { return 10; }
int test3(const int a) { return a + 1; }
int test4(const int const a) { return a + 1; }

Wignored-qualifiers only complains about the return on test2, and without a fixit.

@chandlerc
Copy link
Member

The return type cases I believe are fixed in r126321, thanks to Hans.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@philnik777
Copy link
Contributor

Retargeting as a clang-tidy check. This does make sense in a definition, so it's only a style choice whether to keep the const in the declaration or not.

@philnik777 philnik777 added clang-tidy check-request Request for a new check in clang-tidy and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 22, 2023
@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 22, 2023

@llvm/issue-subscribers-clang-tidy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla check-request Request for a new check in clang-tidy clang-tidy
Projects
None yet
Development

No branches or pull requests

3 participants