================
@@ -3371,6 +3379,20 @@ Sema::ActOnBreakStmt(SourceLocation BreakLoc, Scope
*CurScope) {
if (S->isOpenMPLoopScope())
return StmtError(Diag(BreakLoc, diag::err_omp_loop_cannot_use_stmt)
<< "break");
+
+ // OpenACC doesn't allow 'break'ing from a compute construct, so diagnose if
+ // we are trying to do so. This can come in 2 flavors: 1-the break'able
thing
+ // (besides the compute construct) 'contains' the compute construct, at which
+ // point the 'break' scope will be the compute construct. Else it could be a
+ // loop of some sort that has a direct parent of the compute construct.
+ // However, a 'break' in a 'switch' marked as a compute construct doesn't
+ // count as 'branch out of' the compute construct.
+ if (S->isOpenACCComputeConstructScope() ||
+ (!S->isDirectlySwitchScope() && S->getParent() &&
----------------
erichkeane wrote:
> No problem we're in the same position. :) I'm not asking about the very first
> check, it is ok and I did not ask about it. What I'm asking is exactly the
> second part (after OR, second part of the logic). I'm suggesting instead of
> checking for non-switch just to check explicitly for 'for scope'. "Not switch
> scope" is too broad, I just suggest to check for the scopes, which are not
> allowed instead (isForScope). I think it is much easier to read and
> understand the context.
Ah! So we don't actually HAVE a `ForScope` as far as I can tell, let alone the
`while` or `do-while`: https://clang.llvm.org/doxygen/classclang_1_1Scope.html
Perhaps I could change the name of `isDirectlySwitchScope` to be: `isBreakLoop`
or something, and have it do the inverse of what `isDirectlySwitchScope` does
now?
https://github.com/llvm/llvm-project/pull/82543
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits