Sirraide wrote:

@ojhunt FYI, I think would be easier to add an extra flag to the `Scope` class 
that basically keeps track of whether break/continue are currently allowed and 
only set that right before we start parsing the body. This would be different 
from the BreakScope/ContinueScope flags in that in e.g. `while(({ breka; 
true;})) {}`, we *do* want the enclosing `while` loop to be the parent 
`ContinueScope`—we just don’t want to actually allow `continue`/`break` in it 
yet.

So my suggestion would be to add that flag to Scope and then in 
`Sema::ActOnContinueStmt()` and `Sema::ActOnContinueStmt()`, we check if the 
parent continue/break scope has that flag set and issue a diagnostic if not.

I don’t think changes to codegen should be required at all since this refactor 
shouldn’t introduce any new valid code patterns—it should just disallow 
existing ones.

https://github.com/llvm/llvm-project/pull/152606
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to