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

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 06:41:37 PDT 2024


jyknight wrote:

The part I'm confused about is that this commit doesn't appear to simply be adding "or `alignas`" to some code that said "if `_Alignas`". Yes, the newly added `isAlignas()` checks do cover both attributes, but `_Alignas` was still working even after b9cf7f1.

That is, in clang trunk, this test does still pass when parsed as -std=c23:
```
struct X {
    _Alignas(8) char n;
};

static_assert(_Alignof(struct X) == 8, "");
```

So why does this PR need to add new code to move `alignas`, instead of having `alignas` use whatever codepath was already handling `_Alignas`? Or, alternatively remove whatever code was formerly handling `_Alignas`, in favor of this new code?

Or, are `alignas` and `_Alignas` actually getting parsed differently, even still, so only `alignas` needs to be moved?

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


More information about the cfe-commits mailing list