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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 15 07:37:31 PDT 2026


================
@@ -2379,6 +2382,11 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc,
       return StmtError();
     }
 
+    // attribute-specifier without attribute (`[[]]`) isn't in AST.
+    // `__declspec()` is only applied to declarations, so we can ignore it.
+    if (!isa<CompoundStmt>(Body.get()) || BodyStartsWithAttr)
----------------
AaronBallman wrote:

Possibly. The cases I was worried about for token lookahead also involved lexer stuff like
```
template for (int x : {1})
#pragma clang diagnostic ...
{}
```
and whether anything can usefully produce an annotation token before the compound statement.

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


More information about the cfe-commits mailing list