[clang] [Clang] prevent incorrect rejection of auto with reordered declaration specifiers in C23 (PR #177865)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 26 05:15:43 PST 2026


AaronBallman wrote:

> I am not sure this is the right approach.
> 
>     * There are many more qualifiers (`_Atomic` for example, but look at `isTypeSpecifierQualifier` for more of the complexity)
> 
> 
> I would like @AaronBallman to help us clarify the C23 rules. In particular as @Fznamznon mention, it is odd that `long auto long` would be allowed, although GCC accepts it. Is that a defect?
> 
> The tests should probably check if the behavior is consistent with static/extern

It depends on whether `auto` is being used as a storage class specifier or not. If it's being used as a storage class specifier, then the way the grammar falls out you can do crazy things like [`const long auto long unsigned volatile _Atomic i =12;`](https://godbolt.org/z/TKscPjfhq)
```
long auto long i = 12; // Diagnosed as an invalid use of a storage class specifier
void func() {
  long auto long l1 = 12; // Okay, should be accepted
  static long auto long l2 = 12; // Diagnosed as a duplicate storage class specifier
}
```

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


More information about the cfe-commits mailing list