1932aae77SSourabh Singh Tomar<!--===- docs/LabelResolution.md 2932aae77SSourabh Singh Tomar 3932aae77SSourabh Singh Tomar Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4932aae77SSourabh Singh Tomar See https://llvm.org/LICENSE.txt for license information. 5932aae77SSourabh Singh Tomar SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6932aae77SSourabh Singh Tomar 7932aae77SSourabh Singh Tomar--> 8932aae77SSourabh Singh Tomar 9eaff2004Ssameeran joshi# Semantics: Resolving Labels and Construct Names 10eaff2004Ssameeran joshi 11*b7ff0320Scor3ntin```{contents} 12*b7ff0320Scor3ntin--- 13*b7ff0320Scor3ntinlocal: 14*b7ff0320Scor3ntin--- 15271a7bb1SRichard Barton``` 16271a7bb1SRichard Barton 17eaff2004Ssameeran joshi## Overview 18eaff2004Ssameeran joshi 19eaff2004Ssameeran joshiAfter the Fortran input file(s) has been parsed into a syntax tree, the compiler must check that the program checks semantically. Target labels must be checked and violations of legal semantics should be reported to the user. 20eaff2004Ssameeran joshi 21eaff2004Ssameeran joshiThis is the detailed design document on how these labels will be semantically checked. Legal semantics may result in rewrite operations on the syntax tree. Semantics violations will be reported as errors to the user. 22eaff2004Ssameeran joshi 23eaff2004Ssameeran joshi## Requirements 24eaff2004Ssameeran joshi 25eaff2004Ssameeran joshi- Input: a parse tree that decomposes the Fortran program unit 26eaff2004Ssameeran joshi- Output: 27eaff2004Ssameeran joshi * **Success** returns true 28eaff2004Ssameeran joshi (Additionally, the parse tree may be rewritten on success to capture the nested DO loop structure explicitly from any _label-do-stmt_ type loops.) 29eaff2004Ssameeran joshi * **Failure** returns false, instantiates (a container of) error message(s) to indicate the problem(s) 30eaff2004Ssameeran joshi 31eaff2004Ssameeran joshi 32eaff2004Ssameeran joshi### Label generalities (6.2.5) 33eaff2004Ssameeran joshi 34eaff2004Ssameeran joshiEnforcement of the general label constraints. There are three sorts of label usage. Labels can serve 35eaff2004Ssameeran joshi 1. as a _label-do-stmt_ block range marker 36eaff2004Ssameeran joshi 1. as branching (control flow) targets 37eaff2004Ssameeran joshi 1. as specification annotations (`FORMAT` statements) for data transfer statements (I/O constructs) 38eaff2004Ssameeran joshi 39eaff2004Ssameeran joshiLabels are related to the standard definition of inclusive scope. For example, control-flow arcs are not allowed to originate from one inclusive scope and target statements outside of that inclusive scope. 40eaff2004Ssameeran joshi 41eaff2004Ssameeran joshiInclusive scope is defined as a tree structure of nested scoping constructs. A statement, _s_, is said to be *in* the same inclusive scope as another statement, _t_, if and only if _s_ and _t_ are in the same scope or _t_ is in one of the enclosing scopes of _s_, otherwise _s_ is *not in* the same inclusive scope as _t_. (Inclusive scope is unidirectional and is always from innermost scopes to outermost scopes.) 42eaff2004Ssameeran joshi 43eaff2004Ssameeran joshi#### Semantic Checks 44eaff2004Ssameeran joshi 45eaff2004Ssameeran joshi- labels range from 1 to 99999, inclusive (6.2.5 note 2) 46eaff2004Ssameeran joshi * handled automatically by the parser, but add a range check 47eaff2004Ssameeran joshi- labels must be pairwise distinct within their program unit scope (6.2.5 para 2) 48eaff2004Ssameeran joshi * if redundant labels appear → error redundant labels 49eaff2004Ssameeran joshi * the total number of unique statement labels may have a limit 50eaff2004Ssameeran joshi 51eaff2004Ssameeran joshi 52eaff2004Ssameeran joshi### Labels Used for `DO` Loop Ranging 53eaff2004Ssameeran joshi 54eaff2004Ssameeran joshi#### _label-do-stmt_ (R1121) 55eaff2004Ssameeran joshi 56eaff2004Ssameeran joshiA _label-do-stmt_ is a control construct that results in the iterative execution of a number of statements. A _label-do-stmt_ has a (possibly shared, _nonblock-do-construct_) _label_ that will be called the loop target label. The statements to be executed will be the range from the _label-do-stmt_ to the statement identified by the loop target label, inclusive. This range of statements will be called the loop's body and logically forms a _do-block_. 57eaff2004Ssameeran joshi 58eaff2004Ssameeran joshiA _label-do-stmt_ is quite similar to a _block-do-construct_ in semantics, but the parse tree is different in that the parser does not impose a _do-block_ structure on the loop body. 59eaff2004Ssameeran joshi 60eaff2004Ssameeran joshiIn F18, the nonblock `DO` construct has been removed. For legacy support (through F08), we will need to handle nonblock `DO` constructs. In F18, the following legacy code is an error. 61eaff2004Ssameeran joshi 62eaff2004Ssameeran joshi```fortran 63eaff2004Ssameeran joshi DO 100 I = 1, 100 64eaff2004Ssameeran joshi DO 100 J = 1, 100 65eaff2004Ssameeran joshi ... 66eaff2004Ssameeran joshi 100 CONTINUE 67eaff2004Ssameeran joshi``` 68eaff2004Ssameeran joshi 69eaff2004Ssameeran joshi##### Semantic Checks 70eaff2004Ssameeran joshi 71eaff2004Ssameeran joshi- the loop body target label must exist in the scope (F18:C1133; F08:C815, C817, C819) 72eaff2004Ssameeran joshi * if the label does not appear, error of missing label 73eaff2004Ssameeran joshi- the loop body target label must be, lexically, after the _label-do-stmt_ (R1119) 74eaff2004Ssameeran joshi * if the label appears lexically preceding the `DO`, error of malformed `DO` 75eaff2004Ssameeran joshi- control cannot transfer into the body from outside the _do-block_ 76eaff2004Ssameeran joshi * Exceptions (errors demoted to warnings) 77eaff2004Ssameeran joshi - some implementations relax enforcement of this and allow `GOTO`s from the loop body to "extended ranges" and back again (PGI & gfortan appear to allow, NAG & Intel do not.) 78eaff2004Ssameeran joshi - should some form of "extended ranges" for _do-constructs_ be supported, it should still be limited and not include parallel loops such as `DO CONCURRENT` or loops annotated with OpenACC or OpenMP directives. 79eaff2004Ssameeran joshi * `GOTO`s into the `DO`s inclusive scope, error/warn of invalid transfer of control 80eaff2004Ssameeran joshi- requires that the loop terminating statement for a _label-do-stmt_ be either an `END DO` or a `CONTINUE` 81eaff2004Ssameeran joshi * Exception 82eaff2004Ssameeran joshi - earlier standards allowed other statements to be terminators 83eaff2004Ssameeran joshi 84eaff2004Ssameeran joshiSemantics for F08 and earlier that support sharing the loop terminating statement in a _nonblock-do-construct_ between multiple loops 85eaff2004Ssameeran joshi- some statements cannot be _do-term-action-stmt_ (F08:C816) 86eaff2004Ssameeran joshi * a _do-term-action-stmt_ is an _action-stmt_ but does not include _arithmetic-if-stmt_, _continue-stmt_, _cycle-stmt_, _end-function-stmt_, _end-mp-subprogram-stmt_, _end-program-stmt_, _end-subroutine-stmt_, _error-stop-stmt_, _exit-stmt_, _goto-stmt_, _return-stmt_, or _stop-stmt_ 87eaff2004Ssameeran joshi - if the term action statement is forbidden, error invalid statement in `DO` loop term position 88eaff2004Ssameeran joshi- some statements cannot be _do-term-shared-stmt_ (F08:C818) 89eaff2004Ssameeran joshi * this is the case as in our above example where two different nested loops share the same terminating statement (`100 continue`) 90eaff2004Ssameeran joshi * a _do-term-shared-stmt_ is an _action-stmt_ with all the same exclusions as a _do-term-action-stmt_ except a _continue-stmt_ **is** allowed 91eaff2004Ssameeran joshi - if the term shared action statement is forbidden, error invalid statement in term position 92eaff2004Ssameeran joshi 93eaff2004Ssameeran joshiIf the `DO` loop is a `DO CONCURRENT` construct, there are additional constraints (11.1.7.5). 94eaff2004Ssameeran joshi- a _return-stmt_ is not allowed (C1136) 95eaff2004Ssameeran joshi- image control statements are not allowed (C1137) 96eaff2004Ssameeran joshi- branches must be from a statement and to a statement that both reside within the `DO CONCURRENT` (C1138) 97eaff2004Ssameeran joshi- impure procedures shall not be called (C1139) 98eaff2004Ssameeran joshi- deallocation of polymorphic objects is not allowed (C1140) 99eaff2004Ssameeran joshi- references to `IEEE_GET_FLAG`, `IEEE_SET_HALTING_MODE`, and `IEEE_GET_HALTING_MODE` cannot appear in the body of a `DO CONCURRENT` (C1141) 100eaff2004Ssameeran joshi- the use of the `ADVANCE=` specifier by an I/O statement in the body of a `DO CONCURRENT` is not allowed (11.1.7.5, para 5) 101eaff2004Ssameeran joshi 102eaff2004Ssameeran joshi### Labels Used in Branching 103eaff2004Ssameeran joshi 104eaff2004Ssameeran joshi#### _goto-stmt_ (11.2.2, R1157) 105eaff2004Ssameeran joshi 106eaff2004Ssameeran joshiA `GOTO` statement is a simple, direct transfer of control from the `GOTO` to the labelled statement. 107eaff2004Ssameeran joshi 108eaff2004Ssameeran joshi##### Semantic Checks 109eaff2004Ssameeran joshi 110eaff2004Ssameeran joshi- the labelled statement that is the target of a `GOTO` (11.2.1 constraints) 111eaff2004Ssameeran joshi - must refer to a label that is in inclusive scope of the computed `GOTO` statement (C1169) 112eaff2004Ssameeran joshi * if a label does not exist, error nonexistent label 113eaff2004Ssameeran joshi * if a label is out of scope, error out of inclusive scope 114eaff2004Ssameeran joshi - the branch target statement must be valid 115eaff2004Ssameeran joshi * if the statement is not allowed as a branch target, error not a valid branch target 116eaff2004Ssameeran joshi- the labelled statement must be a branch target statement 117eaff2004Ssameeran joshi * a branch target statement is any of _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_, _forall-stmt_, _where-construct-stmt_, _end-function-stmt_, _end-mp-subprogram-stmt_, _end-program-stmt_, or _end-subroutine-stmt_. (11.2.1) 118eaff2004Ssameeran joshi * Some deleted features that were _action-stmt_ in older standards include _arithmetic-if-stmt_, _assign-stmt_, _assigned-goto-stmt_, and _pause-stmt_. For legacy mode support, these statements should be considered _action-stmt_. 119eaff2004Ssameeran joshi 120eaff2004Ssameeran joshi 121eaff2004Ssameeran joshi#### _computed-goto-stmt_ (11.2.3, R1158) 122eaff2004Ssameeran joshi 123eaff2004Ssameeran joshiThe computed `GOTO` statement is analogous to a `switch` statement in C++. 124eaff2004Ssameeran joshi 125eaff2004Ssameeran joshi```fortran 126eaff2004Ssameeran joshi GOTO ( label-list ) [,] scalar-int-expr 127eaff2004Ssameeran joshi``` 128eaff2004Ssameeran joshi 129eaff2004Ssameeran joshi##### Semantics Checks 130eaff2004Ssameeran joshi 131eaff2004Ssameeran joshi- each label in _label-list_ (11.2.1 constraints, same as `GOTO`) 132eaff2004Ssameeran joshi - must refer to a label that is in inclusive scope of the computed `GOTO` statement (C1170) 133eaff2004Ssameeran joshi * if a label does not exist, error nonexistent label 134eaff2004Ssameeran joshi * if a label is out of scope, error out of inclusive scope 135eaff2004Ssameeran joshi - the branch target statement must be valid 136eaff2004Ssameeran joshi * if the statement is not allowed as a branch target, error not a valid branch target 137eaff2004Ssameeran joshi- the _scalar-int-expr_ needs to have `INTEGER` type 138eaff2004Ssameeran joshi * check the type of the expression (type checking done elsewhere) 139eaff2004Ssameeran joshi 140eaff2004Ssameeran joshi 141eaff2004Ssameeran joshi#### R853 _arithmetic-if-stmt_ (F08:8.2.4) 142eaff2004Ssameeran joshi 143eaff2004Ssameeran joshiThis control-flow construct is deleted in F18. 144eaff2004Ssameeran joshi 145eaff2004Ssameeran joshi```fortran 146eaff2004Ssameeran joshi IF (scalar-numeric-expr) label1,label2,label3 147eaff2004Ssameeran joshi``` 148eaff2004Ssameeran joshi 149eaff2004Ssameeran joshiThe arithmetic if statement is like a three-way branch operator. If the scalar numeric expression is less than zero goto _label-1_, else if the variable is equal to zero goto _label-2_, else if the variable is greater than zero goto _label-3_. 150eaff2004Ssameeran joshi 151eaff2004Ssameeran joshi##### Semantics Checks 152eaff2004Ssameeran joshi 153eaff2004Ssameeran joshi- the labels in the _arithmetic-if-stmt_ triple must all be present in the inclusive scope (F08:C848) 154eaff2004Ssameeran joshi * if a label does not exist, error nonexistent label 155eaff2004Ssameeran joshi * if a label is out of scope, error out of inclusive scope 156eaff2004Ssameeran joshi- the _scalar-numeric-expr_ must not be `COMPLEX` (F08:C849) 157eaff2004Ssameeran joshi * check the type of the expression (type checking done elsewhere) 158eaff2004Ssameeran joshi 159eaff2004Ssameeran joshi 160eaff2004Ssameeran joshi#### _alt-return-spec_ (15.5.1, R1525) 161eaff2004Ssameeran joshi 162eaff2004Ssameeran joshiThese are a Fortran control-flow construct for combining a return from a subroutine with a branch to a labelled statement in the calling routine all in one operation. A typical implementation is for the subroutine to return a hidden integer, which is used as a key in the calling code to then, possibly, branch to a labelled statement in inclusive scope. 163eaff2004Ssameeran joshi 164eaff2004Ssameeran joshiThe labels are passed by the calling routine. We want to check those labels at the call-site, that is instances of _alt-return-spec_. 165eaff2004Ssameeran joshi 166eaff2004Ssameeran joshi##### Semantics Checks 167eaff2004Ssameeran joshi 168eaff2004Ssameeran joshi- each _alt-return-spec_ (11.2.1 constraints, same as `GOTO`) 169eaff2004Ssameeran joshi - must refer to a label that is in inclusive scope of the `CALL` statement 170eaff2004Ssameeran joshi * if a label does not exist, error nonexistent label 171eaff2004Ssameeran joshi * if a label is out of scope, error out of inclusive scope 172eaff2004Ssameeran joshi - the branch target statement must be valid 173eaff2004Ssameeran joshi * if the statement is not allowed as a branch target, error not a valid branch target 174eaff2004Ssameeran joshi 175eaff2004Ssameeran joshi 176eaff2004Ssameeran joshi#### **END**, **EOR**, **ERR** specifiers (12.11) 177eaff2004Ssameeran joshi 178eaff2004Ssameeran joshiThese specifiers can appear in I/O statements and can transfer control to specific labelled statements under exceptional conditions like end-of-file, end-of-record, and other error conditions. (The PGI compiler adds code to test the results from the runtime routines to determine if these branches should take place.) 179eaff2004Ssameeran joshi 180eaff2004Ssameeran joshi##### Semantics Checks 181eaff2004Ssameeran joshi 182eaff2004Ssameeran joshi- each END, EOR, and ERR specifier (11.2.1 constraints, same as `GOTO`) 183eaff2004Ssameeran joshi - must refer to a label that is in inclusive scope of the I/O statement 184eaff2004Ssameeran joshi * if a label does not exist, error nonexistent label 185eaff2004Ssameeran joshi * if a label is out of scope, error out of inclusive scope 186eaff2004Ssameeran joshi - the branch target statement must be valid 187eaff2004Ssameeran joshi * if the statement is not allowed as a branch target, error not a valid branch target 188eaff2004Ssameeran joshi 189eaff2004Ssameeran joshi#### _assigned-goto-stmt_ and _assign-stmt_ (F90:8.2.4) 190eaff2004Ssameeran joshi 191eaff2004Ssameeran joshiDeleted feature since Fortran 95. 192eaff2004Ssameeran joshi 193eaff2004Ssameeran joshiThe _assigned-goto-stmt_ and _assign-stmt_ were _action-stmt_ in the Fortran 90 standard. They are included here for completeness. This pair of obsolete statements can (will) be enabled as part of the compiler's legacy Fortran support. 194eaff2004Ssameeran joshi 195eaff2004Ssameeran joshiThe _assign-stmt_ stores a _label_ in an integer variable. The _assigned-goto-stmt_ will then transfer control to the _label_ stored in that integer variable. 196eaff2004Ssameeran joshi 197eaff2004Ssameeran joshi```fortran 198eaff2004Ssameeran joshi ASSIGN 10 TO i 199eaff2004Ssameeran joshi ... 200eaff2004Ssameeran joshi GOTO i (10,20,30) 201eaff2004Ssameeran joshi``` 202eaff2004Ssameeran joshi 203eaff2004Ssameeran joshi##### Semantic Checks 204eaff2004Ssameeran joshi 205eaff2004Ssameeran joshi- an _assigned-goto-stmt_ cannot be a _do-term-action-stmt_ (F90:R829) 206eaff2004Ssameeran joshi- an _assigned-goto-stmt_ cannot be a _do-term-shared-stmt_ (F90:R833) 207eaff2004Ssameeran joshi- constraints from (F90:R839) 208eaff2004Ssameeran joshi - each _label_ in an optional _label-list_ must be the statement label of a branch target statement that appears in the same scoping unit as the _assigned-goto-stmt_ 209eaff2004Ssameeran joshi - _scalar-int-variable_ (`i` in the example above) must be named and of type default integer 210eaff2004Ssameeran joshi - an integer variable that has been assigned a label may only be referenced in an _assigned-goto_ or as a format specifier in an I/O statement 211eaff2004Ssameeran joshi - when an I/O statement with a _format-specifier_ that is an integer variable is executed or when an _assigned-goto_ is executed, the variable must have been assigned a _label_ 212eaff2004Ssameeran joshi - an integer variable can only be assigned a label via the `ASSIGN` statement 213eaff2004Ssameeran joshi - the label assigned to the variable must be in the same scoping unit as the _assigned-goto_ that branches to the _label_ value 214eaff2004Ssameeran joshi - if the parameterized list of labels is present, the label value assigned to the integer variable must appear in that _label-list_ 215eaff2004Ssameeran joshi - a distinct _label_ can appear more than once in the _label-list_ 216eaff2004Ssameeran joshi 217eaff2004Ssameeran joshiSome interpretation is needed as the terms of the older standard are different. 218eaff2004Ssameeran joshi 219eaff2004Ssameeran joshiA "scoping unit" is defined as 220eaff2004Ssameeran joshi - a derived-type definition 221eaff2004Ssameeran joshi - a procedure interface body, excluding derived-types and interfaces contained within it 222eaff2004Ssameeran joshi - a program unit or subprogram, excluding derived-types, interfaces, and subprograms contained within it 223eaff2004Ssameeran joshi 224eaff2004Ssameeran joshiThis is a more lax definition of scope than inclusive scope. 225eaff2004Ssameeran joshi 226eaff2004Ssameeran joshiA _named variable_ distinguishes a variable such as, `i`, from an element of an array, `a(i)`, for example. 227eaff2004Ssameeran joshi 228eaff2004Ssameeran joshi### Labels used in I/O 229eaff2004Ssameeran joshi 230eaff2004Ssameeran joshi#### Data transfer statements 231eaff2004Ssameeran joshi 232eaff2004Ssameeran joshiIn data transfer (I/O) statements (e.g., `READ`), the user can specify a `FMT=` specifier that can take a label as its argument. (R1215) 233eaff2004Ssameeran joshi 234eaff2004Ssameeran joshi##### Semantic Checks 235eaff2004Ssameeran joshi 236eaff2004Ssameeran joshi- if the `FMT=` specifier has a label as its argument (C1230) 237eaff2004Ssameeran joshi - the label must correspond to a `FORMAT` statement 238eaff2004Ssameeran joshi * if the statement is not a `FORMAT`, error statement must be a `FORMAT` 239eaff2004Ssameeran joshi - the labelled `FORMAT` statement must be in the same inclusive scope as the originating data transfer statement (also in 2008) 240eaff2004Ssameeran joshi * if the label statement does not exist, error label does not exist 241eaff2004Ssameeran joshi * if the label statement is not in scope, error label is not in inclusive scope 242eaff2004Ssameeran joshi - Exceptions (errors demoted to warnings) 243eaff2004Ssameeran joshi - PGI extension: referenced `FORMAT` statements may appear in a host procedure 244eaff2004Ssameeran joshi - Possible relaxation: the scope of the referenced `FORMAT` statement may be ignored, allowing a `FORMAT` to be referenced from any scope in the compilation. 245eaff2004Ssameeran joshi 246eaff2004Ssameeran joshi### Construct Name generalities 247eaff2004Ssameeran joshi 248eaff2004Ssameeran joshiVarious Fortran constructs can have names. These include 249eaff2004Ssameeran joshi - the `WHERE` construct (10.2.3) 250eaff2004Ssameeran joshi - the `FORALL` construct (10.2.4) 251eaff2004Ssameeran joshi - the `ASSOCIATE` construct (11.1.3) 252eaff2004Ssameeran joshi - the `BLOCK` construct (11.1.4) 253eaff2004Ssameeran joshi - the `CHANGE TEAM` construct (11.1.5) 254eaff2004Ssameeran joshi - the `CRITICAL` construct (11.1.6) 255eaff2004Ssameeran joshi - the `DO` construct (11.1.7) 256eaff2004Ssameeran joshi - the `IF` construct (11.1.8) 257eaff2004Ssameeran joshi - the `SELECT CASE` construct (11.1.9) 258eaff2004Ssameeran joshi - the `SELECT RANK` construct (11.1.10) 259eaff2004Ssameeran joshi - the `SELECT TYPE` construct (11.1.11) 260eaff2004Ssameeran joshi 261eaff2004Ssameeran joshi#### Semantics Checks 262eaff2004Ssameeran joshi 263eaff2004Ssameeran joshiA construct name is a name formed under 6.2.2. A name is an identifier. Identifiers are parsed by the parser. 264eaff2004Ssameeran joshi - the maximum length of a name is 63 characters (C601) 265eaff2004Ssameeran joshi 266eaff2004Ssameeran joshiNames must either not be given for the construct or used throughout when specified. 267eaff2004Ssameeran joshi- if a construct is given a name, the construct's `END` statement must also specify the same name (`WHERE` C1033, `FORALL` C1035, ...) 268eaff2004Ssameeran joshi- `WHERE` has additional `ELSEWHERE` clauses 269eaff2004Ssameeran joshi- `IF` has additional `ELSE IF` and `ELSE` clauses 270eaff2004Ssameeran joshi- `SELECT CASE` has additional `CASE` clauses 271eaff2004Ssameeran joshi- `SELECT RANK` has additional `RANK` clauses 272eaff2004Ssameeran joshi- `SELECT TYPE` has additional _type-guard-stmt_ 273eaff2004Ssameeran joshiThese additional statements must meet the same constraint as the `END` of the construct. Names must match, if present, or there must be no names for any of the clauses. 274eaff2004Ssameeran joshi 275eaff2004Ssameeran joshi### `CYCLE` statement (11.1.7.4.4) 276eaff2004Ssameeran joshi 277eaff2004Ssameeran joshiThe `CYCLE` statement takes an optional _do-construct-name_. 278eaff2004Ssameeran joshi 279eaff2004Ssameeran joshi#### Semantics Checks 280eaff2004Ssameeran joshi 281eaff2004Ssameeran joshi- if the `CYCLE` has a _construct-name_, then the `CYCLE` statement must appear within that named _do-construct_ (C1134) 282eaff2004Ssameeran joshi- if the `CYCLE` does not have a _do-construct-name_, the `CYCLE` statement must appear within a _do-construct_ (C1134) 283eaff2004Ssameeran joshi 284eaff2004Ssameeran joshi### `EXIT` statement (11.1.12) 285eaff2004Ssameeran joshi 286eaff2004Ssameeran joshiThe `EXIT` statement takes an optional _construct-name_. 287eaff2004Ssameeran joshi 288eaff2004Ssameeran joshi#### Semantics Checks 289eaff2004Ssameeran joshi 290eaff2004Ssameeran joshi- if the `EXIT` has a _construct-name_, then the `EXIT` statement must appear within that named construct (C1166) 291eaff2004Ssameeran joshi- if the `EXIT` does not have a _construct-name_, the `EXIT` statement must appear within a _do-construct_ (C1166) 292eaff2004Ssameeran joshi- an _exit-stmt_ must not appear in a `DO CONCURRENT` if the `EXIT` belongs to the `DO CONCURRENT` or an outer construct enclosing the `DO CONCURRENT` (C1167) 293eaff2004Ssameeran joshi- an _exit-stmt_ must not appear in a `CHANGE TEAM` (`CRITICAL`) if the `EXIT` belongs to an outer construct enclosing the `CHANGE TEAM` (`CRITICAL`) (C1168) 294eaff2004Ssameeran joshi 295