[clang] Fix a regression with alignas on structure members in C (PR #98642)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 06:09:28 PDT 2024


AaronBallman wrote:

> I'm not sure I understand what happened here, since `_Alignas` did work properly before this change, right? How/why are `_Alignas` and `alignas` acting differently from eachother in C23 mode?

`_Alignas` on a field used to work properly before b9cf7f1066cc7ec11c6074d10b0f2ec9a3ae72d9, but that commit changed `alignas` handling improperly. The issue boils down to the fact that C++ treats `alignas` as an attribute and C treats `_Alignas` (and now `alignas` as of C23) as a type specifier rather than an attribute. We were originally leaning on the C++ implementation when the keyword was spelled `alignas` and we missed some changes to make that work in C, which is what this commit is addressing (by ensuring the attribute moves onto the declarator where it belongs and used to be found).

https://github.com/llvm/llvm-project/pull/98642


More information about the cfe-commits mailing list