================
@@ -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);
----------------
akash-manna-sky wrote:
> That's a good point; we drop the AST node in this case because it's not valid
> to emit, but that's still leading to CodeGen crashes:
> https://godbolt.org/z/58rfvnfhY
>
> Given the `RecoveryExpr`, we shouldn't be getting that far into codegen in
> the first place, should we?
Right. `int;` gave an invalid statement with no diagnostic, so the
`RecoveryExpr` came with zero errors. With this PR Sema reports the void
condition, so CodeGen isn't reached (`d2` in `Sema/GH215454.c`).
https://github.com/llvm/llvm-project/pull/224682
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits