[flang-commits] [flang] [flang] Do not branch to a FORMAT statement from an assigned GO TO (PR #217220)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Fri Aug 21 01:48:09 PDT 2026


================
@@ -1067,7 +1082,7 @@ class PFTBuilder {
                 auto iter = assignSymbolLabelMap->find(*sym);
                 if (iter != assignSymbolLabelMap->end())
                   for (auto label : iter->second)
-                    markBranchTarget(eval, label);
+                    markIfBranchTarget(label);
----------------
ergawy wrote:

I think it would be better to make `AssignStmt` use the same semantic mechanism used by `AssignedGotoStmt` (whatever that check is).

The whole idea behind trying to come up with a positive check (i.e. classify what is a valid branch target) vs. negative check(s) (like checking explicitly for a FORMAT statement) is to make sure we do not have to enumerate all negative cases. That's why I would prefer the current positive check.

The spec states explictely what is a branch target:
> ### 11.2.1 Branch concepts
> 1  Branching is used to alter the normal execution sequence. A branch causes a transfer of control from one statement to a labeled branch target statement in the same inclusive scope. Branching can be caused by a GO TO statement, a computed GO TO statement, a CALL statement that has an *alt-return-spec*, or an input/output statement that has an END=, EOR=, or ERR= specifier. Although procedure references and control constructs can cause transfer of control, they are not branches. A branch target statement is an *action-stmt*, *associate-stmt*, *end-associate-stmt*, *if-then-stmt*, *end-if-stmt*, *select-case-stmt*, *end-select-stmt*, *select-rank-stmt*, *end-select-rank-stmt*, *select-type-stmt*, *end-select-type-stmt*, *do-stmt*, *end-do-stmt*, *block-stmt*, *end-block-stmt*, *critical-stmt*, *end-critical-stmt*, *forall-construct-stmt*, *where-construct-stmt*, *end-function-stmt*, *end-mp-subprogram-stmt*, *end-program-stmt*, or *end-subroutine-stmt*.

It does not, on the other hand, specify a negative list of what is not.

https://github.com/llvm/llvm-project/pull/217220


More information about the flang-commits mailing list