[clang] [clang] Add break/continue stmts with missing lable to the AST (PR #168332)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 17 06:03:15 PST 2025
================
@@ -2313,10 +2313,8 @@ StmtResult Parser::ParseBreakOrContinueStatement(bool IsContinue) {
// TODO: Make this a compatibility/extension warning instead once the
// syntax of this feature is finalised.
Diag(LabelLoc, diag::err_c2y_labeled_break_continue) << IsContinue;
- if (!Target) {
+ if (!Target)
Diag(LabelLoc, diag::err_break_continue_label_not_found) << IsContinue;
- return StmtError();
----------------
AaronBallman wrote:
`CFG::buildCFG()` has no checks that anything is valid; I was thinking the check was based on whether there was an invalid bit set somewhere, but that's not the case for constructing the CFG. Instead, `AnalysisBasedWarnings::IssueWarnings()` looks for whether there's been any compilation errors before deciding whether to construct the CFG. So this change "works" for anyone holding the CFG that way, but anyone with custom CFG use will get odd behavior. (I didn't check how the static analyzer uses it, how clang-tidy uses it, there's plugins to consider as well.)
> I feel like the main issue here is the fact that we’re trying to constant-evaluate a function that contains an error... which is a bit questionable imo.
+1, I would expect us to fail early rather than try to continue compilation in this case.
https://github.com/llvm/llvm-project/pull/168332
More information about the cfe-commits
mailing list