[clang] [Clang] [Sema] Allow non-local/non-variable declarations in for loop (PR #129737)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 7 05:48:14 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())
----------------
Sirraide wrote:
There is a C99 quote further up above on line 2264; we could add a comment that mentions that this changed at some point though. Something like ‘C23 has no such restriction’ maybe?
https://github.com/llvm/llvm-project/pull/129737
More information about the cfe-commits
mailing list