# dmd.statementsem

Does semantic analysis for statements.

Specification: Statements

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: statementsem.d

Documentation: https://dlang.org/phobos/dmd_statementsem.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/statementsem.d

- `throwSemantic`

  #### Declaration

  `bool `throwSemantic`(const ref Loc `loc`, ref Expression `exp`, Scope* `sc`);`

  Run semantic on `throw <`exp`>`.

  #### Parameters

  `Loc `loc`` | location of the `throw`
  `Expression `exp`` | value to be thrown
  `Scope* `sc`` | enclosing scope

  #### Return Value

  `true` if the `throw` is valid, or `false` if an error was found

- `scopeCode`

  #### Declaration

  `Statement `scopeCode`(Statement `statement`, Scope* `sc`, out Statement `sentry`, out Statement `sexception`, out Statement `sfinally`);`

  If ``statement`` has code that needs to run in a finally clause at the end of the current scope, return that code in the form of a Statement.

  #### Parameters

  `Statement `statement`` | the `statement`
  `Scope* `sc`` | context
  `Statement `sentry`` | set to code executed upon entry to the scope
  `Statement `sexception`` | set to code executed upon exit from the scope via exception
  `Statement `sfinally`` | set to code executed in finally block

  #### Return Value

  code to be run in the finally clause

- `makeTupleForeach`

  #### Declaration

  `auto `makeTupleForeach`(Scope* `sc`, bool `isStatic`, bool `isDecl`, ForeachStatement `fs`, Dsymbols* `dbody`, bool `needExpansion`);`

  Type check and unroll `foreach` over an expression tuple as well as `static foreach` statements and `static foreach` declarations. For `static foreach` statements and `static foreach` declarations, the visitor interface is used (and the result is written into the `result` field.) For `static foreach` declarations, the resulting Dsymbols* are returned directly.

  #### Discussion

  The unrolled body is wrapped into a

  - UnrolledLoopStatement, for `foreach` over an expression tuple.
  - ForwardingStatement, for `static foreach` statements.
  - ForwardingAttribDeclaration, for `static foreach` declarations.
  `static foreach` variables are declared as `STC.local`, such that they are inserted into the local symbol tables of the forwarding constructs instead of forwarded. For `static foreach` with multiple foreach loop variables whose aggregate has been lowered into a sequence of tuples, this function expands the tuples into multiple `STC.local` `static foreach` variables.
- `pragmaMsgSemantic`

  #### Declaration

  `bool `pragmaMsgSemantic`(Loc `loc`, Scope* `sc`, Expressions* `args`);`

  Evaluate and print a `pragma(msg, `args`)`

  #### Parameters

  `Loc `loc`` | location for error messages
  `Scope* `sc`` | scope for argument interpretation
  `Expressions* `args`` | expressions to print

  #### Return Value

  `true` on success

- `pragmaStartAddressSemantic`

  #### Declaration

  `bool `pragmaStartAddressSemantic`(Loc `loc`, Scope* `sc`, Expressions* `args`);`

  Evaluate `pragma(startAddress, func)` and store the resolved symbol in ``args``

  #### Parameters

  `Loc `loc`` | location for error messages
  `Scope* `sc`` | scope for argument interpretation
  `Expressions* `args`` | pragma arguments

  #### Return Value

  `true` on success