STGOPT

The STGOPT option controls storage optimization.

STGOPT option syntax

Read syntax diagramSkip visual syntax diagramNOSTGOPTSTGOPT

Default is: NOSTGOPT

Abbreviations are: SO | NOSO

If you specify STGOPT, the compiler might discard any or all of the following data items, and does not allocate storage for them.
  • Start of changeUnreferenced LOCAL-STORAGE and WORKING-STORAGE level-77 and level-01 elementary data itemsEnd of change
  • Start of changeLevel-01 group items if none of their subordinate items are referencedEnd of change
  • Unreferenced special registers
Note: The STGOPT option is ignored for data items that have the VOLATILE clause. For details, see VOLATILE clause.
The compiler will not generate code to initialize discarded data items to the values in their VALUE clauses.

In addition, with STGOPT, data items in the LOCAL-STORAGE SECTION can be reordered in memory to optimize performance.

Start of changeWhen NOSTGOPT is in effect, the storage for all data items, including unreferenced data items, is allocated by the compiler, data items are never reordered to improve performance, and all data items defined with a VALUE clause are guaranteed to be initialized, even if they are unreferenced. End of change

Start of changeYou can also use the RULES(UNREF | NOUNREFALL | NOUNREFSOURCE) option to control whether to issue warning messages for unreferenced data items. For details, see RULES.End of change