[clang] [Clang] Don't treat a declaration that declares nothing as an invalid statement (PR #224682)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 07:14:01 PDT 2026
================
@@ -231,6 +231,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
GNUAttrs.Range.getBegin());
} else if (GNUAttrs.Range.getBegin().isValid())
DeclStart = GNUAttrs.Range.getBegin();
+ // A declaration that declares nothing (`int;`) yields no Decl but still
+ // occupies the statement position; unlike a pragma, ParseStatement() must
+ // not skip it.
+ if (!Decl)
+ return Actions.ActOnNullStmt(PrevTokLocation);
----------------
AaronBallman wrote:
Won't this change behavior around diagnostics for code like:
```
if (1)
int; // Declaration is not fine, should be diagnosed
```
https://godbolt.org/z/Pz6Mvvjnb
https://github.com/llvm/llvm-project/pull/224682
More information about the cfe-commits
mailing list