[clang] [clang] Reject 'auto' storage class with type specifier in C++ (PR #166004)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 3 06:54:21 PST 2025
================
@@ -5,14 +5,18 @@
// The auto or register specifiers can be applied only to names of objects
// declared in a block (6.3) or to function parameters (8.4).
-auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
+auto int ao;
#if __cplusplus >= 201103L // C++11 or later
-// expected-warning at -2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
+// expected-error at -2 {{'auto' cannot be combined with a type specifier}}
+#else
+// expected-error at -4 {{illegal storage class on file-scoped variable}}
----------------
AaronBallman wrote:
It'd be slightly easier to review this file if we used `-verify=` and different prefixes instead of preprocessor conditionals, but I don't insist on a change for this PR either unless others have strong feelings.
https://github.com/llvm/llvm-project/pull/166004
More information about the cfe-commits
mailing list