-
Notifications
You must be signed in to change notification settings - Fork 13.4k
_Alignas on a struct declaration gives a low-quality diagnostic #58637
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
Comments
@llvm/issue-subscribers-c11 |
@llvm/issue-subscribers-good-first-issue |
Here's an attempt at a fix: |
@AaronBallman , I will like work on this issue, @theo-lw are you still working on this? |
Hi, I'm trying to take a shot at this building on top of D141177 and its existing review. My active branch is here. I'm looking for some clarification w.r.t the solution before bringing in any review. Changes in bd41371 has D141177 outdated. I was expecting to use the replacements - something like Looks like I'm running into a few problems:
|
Fixes #58637. Adds `isAlignas()` method on `AttributeCommonInfo` which accounts for C++ `alignas` as well as C11 `_Alignas`. The method is used to improve diagnostic in C when `_Alignas` is used in C at the wrong location. This corrects the previously suggested move of `_Alignas` past the declaration specifier, now warns attribute `_Alignas` is ignored. Based on https://reviews.llvm.org/D141177.
Fixes llvm/llvm-project#58637. Adds `isAlignas()` method on `AttributeCommonInfo` which accounts for C++ `alignas` as well as C11 `_Alignas`. The method is used to improve diagnostic in C when `_Alignas` is used in C at the wrong location. This corrects the previously suggested move of `_Alignas` past the declaration specifier, now warns attribute `_Alignas` is ignored. Based on https://reviews.llvm.org/D141177.
gives the diagnostic:
warning: attribute '_Alignas' is ignored, place it after "struct" to apply attribute to type declaration
which seems like a really helpful message at first glance. However, C does not allow you to put an_Alignas
specifier on the struct type itself. So following that advice:gives:
error: declaration of anonymous struct must be a definition
andwarning: declaration does not declare anything
.The original diagnostic should say the attribute is ignored without the helpful message about placement (which is correct for C++).
The text was updated successfully, but these errors were encountered: