[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:39:33 PST 2026
ojhunt wrote:
> ## Pull request overview
> This PR fixes a crash in Clang's CodeGen phase that occurred when a GNU statement expression ended with `extern void;` preceded by other statements. The crash happened because the parser incorrectly treated warnings as errors, causing invalid recovery expressions to leak into CodeGen.
>
> **Changes:**
>
> * Modified `ParseCompoundStatementBody` to only set `LastIsError` when actual error diagnostics are emitted, not just warnings
> * Added regression test covering multi-statement and single-statement cases with `extern void;`
>
> ### Reviewed changes
> Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
>
> File Description
> clang/test/CodeGen/stmt-expr-void-cast.c Regression test with three test cases verifying that `extern void;` in statement expressions no longer crashes and properly emits type-checking errors
> clang/lib/Parse/ParseStmt.cpp Fixed error tracking logic in `ParseCompoundStatementBody` to distinguish between warnings and errors by checking diagnostic count
https://github.com/llvm/llvm-project/pull/181579
More information about the cfe-commits
mailing list