[clang] [Clang][Parse] Fix crash on stmt-expr ending with 'extern void;' (PR #181579)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 21 18:32:33 PST 2026
================
@@ -1214,7 +1216,14 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
if (R.isUsable())
Stmts.push_back(R.get());
- LastIsError = R.isInvalid();
+ // Only treat the last statement as an error if an actual error diagnostic
+ // was emitted during parsing. Constructs like "extern void;" may produce
+ // an invalid StmtResult (via null DeclGroup) with only a warning, which
+ // should not cause the entire compound statement to fail in a stmt-expr.
+ // See https://github.com/llvm/llvm-project/issues/173921
----------------
ojhunt wrote:
This comment is unnecessary, and reads like AI?
https://github.com/llvm/llvm-project/pull/181579
More information about the cfe-commits
mailing list