[clang] [Clang] [Sema] Allow non-local/non-variable declarations in for loop (PR #129737)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 6 17:55:52 PST 2025


================
@@ -2269,10 +2269,11 @@ StmtResult Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
       for (auto *DI : DS->decls()) {
         if (VarDecl *VD = dyn_cast<VarDecl>(DI)) {
           VarDeclSeen = true;
-          if (VD->isLocalVarDecl() && !VD->hasLocalStorage()) {
-            Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-            DI->setInvalidDecl();
-          }
+          if (VD->isLocalVarDecl() && !VD->hasLocalStorage())
----------------
shafik wrote:

I am a big fan of quoting the section of the standard that allows various features. This allows folks in the future to know where to look to better understand the code.

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


More information about the cfe-commits mailing list