[clang] [Clang] Don't treat a declaration that declares nothing as an invalid statement (PR #224682)
Akash Manna via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 06:21:50 PDT 2026
================
@@ -77,8 +77,10 @@ StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
SourceLocation EndLoc) {
DeclGroupRef DG = dg.get();
- // If we have an invalid decl, just return an error.
- if (DG.isNull()) return StmtError();
+ // No declarations, so no statement. This is not an error: `int;` only warns,
+ // and a group emptied by an error was already diagnosed.
+ if (DG.isNull())
+ return StmtEmpty();
----------------
akash-manna-sky wrote:
I agreed!. The parser builds the null statement itself when the declaration produced nothing, and `ActOnDeclStmt` is unchanged.
https://github.com/llvm/llvm-project/pull/224682
More information about the cfe-commits
mailing list