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

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 14 07:05:06 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);
+
----------------
zwuis wrote:

Copied from changes in this PR:

> ```cpp
> // attribute-specifier without attribute (`[[]]`) isn't in AST.
> ```

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


More information about the cfe-commits mailing list