Skip to content

Commit 57bf586

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd502822e682a' from llvm.org/release/21.x into stable/21.x
2 parents 732e399 + d502822 commit 57bf586

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/Sema/SemaStmt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,11 @@ StmtResult Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
22962296
// we can diagnose if we don't see any variable declarations. This
22972297
// covers a case like declaring a typedef, function, or structure
22982298
// type rather than a variable.
2299-
NonVarSeen = DI;
2299+
//
2300+
// Note, _Static_assert is acceptable because it does not declare an
2301+
// identifier at all, so "for object having" does not apply.
2302+
if (!isa<StaticAssertDecl>(DI))
2303+
NonVarSeen = DI;
23002304
}
23012305
}
23022306
// Diagnose if we saw a non-variable declaration but no variable

clang/test/Sema/for.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ void b11 (void) { for (static _Thread_local struct { int i; } s;s.i;); } /* c11-
2626
#endif
2727

2828
void b12(void) {
29-
for(_Static_assert(1, "");;) {} /* c11-warning {{non-variable declaration in 'for' loop is a C23 extension}}
30-
c23-warning {{non-variable declaration in 'for' loop is incompatible with C standards before C23}} */
29+
for(_Static_assert(1, "");;) {} /* okay, _Static_assert declares *no* identifiers */
3130
}

0 commit comments

Comments
 (0)