[clang] [clang] Reject 'auto' storage class with type specifier in C++ (PR #166004)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 3 11:22:22 PST 2025


================
@@ -42,7 +42,12 @@ void p3example() {
   static auto y = 0.0;
----------------
zygoloid wrote:

> Hmmm, it seems we're treating type deduction as an extension in C++98 mode, but we don't list it in the language extensions page as such and we don't issue pedantic diagnostics for it. @zygoloid do you recall if this was an intentional extension or not?

I see a diagnostic for it appearing in all of your test cases:

```
<source>:2:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
    2 |   static auto y = 0.0;
      |     
```

... and `-pedantic-errors` does promote that to an error. So yeah, this is an intentional extension, from the general category of [feature from a later language mode accepted in earlier language modes](https://clang.llvm.org/docs/LanguageExtensions.html#language-extensions-back-ported-to-previous-standards), but I guess the table in our documentation is incomplete -- it only seems to include the C++ features with feature test macros (plus one that I guess postdates the table).

If we want that table to be complete, it's probably worth going through the diagnostics in the `-Wc++XY-extensions` groups and making sure they're all listed. All the relevant extensions should have diagnostics already.

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


More information about the cfe-commits mailing list