================
@@ -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:

> Well what we have is RecoveryExpr and Expr::containsErrors, but none of those 
> are used for broken break statements (one of the reasons being that they 
> aren't expressions).

As best I can tell, we usually don't have to mark the statement as invalid 
because 1) either was syntactically invalid in which case we usually don't add 
the statement to the AST to begin with (https://godbolt.org/z/WjGYn4cGe), or 2) 
it's an expression that's the problem. The same is true here, just in a bit of 
a weird way: the label name is a kind of `DeclRefExpr` (notionally), so `break 
unknown` should be handled the same as `if (unknown)` in that we'd form the 
`BreakStmt` but mark the operand as an invalid expression 
(https://godbolt.org/z/xdsnWb79s). But we don't implement the feature that way, 
we model it after `goto`, both of which skip a notional `DeclRefExpr` and just 
refer to the `LabelDecl` being jumped to directly; maybe the way forward is to 
gin up an invalid `LabelDecl` in this case?

https://github.com/llvm/llvm-project/pull/168332
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to