[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
Thu Jan 29 06:37:04 PST 2026


================
@@ -4093,7 +4093,26 @@ void Parser::ParseDeclarationSpecifiers(
       break;
     case tok::kw_auto:
       if (getLangOpts().CPlusPlus11 || getLangOpts().C23) {
-        if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
+        auto MayBeTypeSpecifier = [&]() {
+          if (getLangOpts().C23 && DS.hasTypeSpecifier() &&
+              DS.getTypeSpecType() != DeclSpec::TST_auto &&
+              DS.getConstexprSpecifier() == ConstexprSpecKind::Unspecified)
+            return true;
+
+          unsigned I = 1;
+          while (true) {
----------------
AaronBallman wrote:

Outside of C23 mode, do we need to do this lookahead? e.g., should the code path for C++ remain the same as it was before?

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


More information about the cfe-commits mailing list