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

Unknown type attributes are diagnosed twice with [[]] spelling #54817

Closed
AaronBallman opened this issue Apr 8, 2022 · 6 comments
Closed

Unknown type attributes are diagnosed twice with [[]] spelling #54817

AaronBallman opened this issue Apr 8, 2022 · 6 comments
Labels
c++11 c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party good first issue https://github.com/llvm/llvm-project/contribute

Comments

@AaronBallman
Copy link
Collaborator

Consider:

void func(void) {
  int [[attr]] i;
  (void)sizeof(int [[attr]]);
}

This generates four diagnostics, two for each unknown attribute. See https://godbolt.org/z/r6eGx1W6E for an example. The same does not happen for declaration attributes or statement attributes, and it does not happen for unknown type attributes spelled with __attribute__.

@AaronBallman AaronBallman added good first issue https://github.com/llvm/llvm-project/contribute c++11 c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party labels Apr 8, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2022

@llvm/issue-subscribers-good-first-issue

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2022

@llvm/issue-subscribers-c-11

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2022

@llvm/issue-subscribers-c2x

@ps-19
Copy link
Contributor

ps-19 commented Apr 8, 2022

Sir can you please give little hint on how can one resolve this issue?

@AaronBallman
Copy link
Collaborator Author

The way I'd approach this is to look at all the places where warn_unknown_attribute_ignored shows up in diagnostic code. I'd see what code paths are taken that lead to diagnosing it twice, and then see if there's a way to ensure that doesn't happen (without breaking any existing tests).

@junaire
Copy link
Member

junaire commented Apr 9, 2022

A potential fix: https://reviews.llvm.org/D123447

mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Don't warn on unknown type attributes in Parser::ProhibitCXX11Attributes
for most cases, but left the diagnostic to the later checks.
module declaration and module import declaration are special cases.

Fixes llvm/llvm-project#54817

Differential Revision: https://reviews.llvm.org/D123447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++11 c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
Development

No branches or pull requests

4 participants