[clang] [clang][Parser] Warn when the body of expansion statement is not a compound statement (PR #209229)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 14 06:30:13 PDT 2026


================
@@ -2379,6 +2383,9 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc,
       return StmtError();
     }
 
+    if (!isa<CompoundStmt>(Body.get()) || BodyStartsWithSquare)
+      Diag(BodyBeginLoc, diag::ext_expansion_stmt_missing_braces);
+
----------------
cor3ntin wrote:

although, you could check for `AttributedStmt`, i think this would be cleaner than looking for a `[`

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


More information about the cfe-commits mailing list