[clang] [clang] Reject 'auto' storage class with type specifier in C++ (PR #166004)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 19 06:42:55 PST 2025
================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
+
+// Test that 'auto' cannot be combined with a type specifier in C++.
+void f() {
+ auto int x = 1; // expected-error {{'auto' cannot be combined with a type specifier}}
----------------
AaronBallman wrote:
What kind of test failures are you seeing, exactly?
Btw, I think it should be `TryAnnotateTypeOrScopeToken(AllowImplicitTypename)` instead of `()`; that's an optional parameter, but one that is relevant to `ParseDeclarationSpecifiers()`.
Do we maybe also need to do `TryAnnotateTypeConstraint()` as well?
CC @erichkeane @mizvekov
https://github.com/llvm/llvm-project/pull/166004
More information about the cfe-commits
mailing list