cobol: Make pointer to stash location file-static.
COBOL compiler fixes an ICE by giving a stash pointer file-static scope, resolving context mismatch issues.
The COBOL compiler used a stash to temporarily store original values during assignments with ON SIZE ERROR clauses. An issue where the stash pointer was declared as an automatic variable but assigned to a static tree led to an Internal Compiler Error (ICE) due to incorrect context handling. This change resolves the ICE by giving the stash pointer file-static scope.
In Details
The move_helper function in cobol/move.cc uses a temporary stash to preserve the destination's original value for ON SIZE ERROR clauses. Previously, the tree stash pointer was an automatic variable within move_helper but was assigned to a static tree node. This mismatch caused context errors during compilation, manifesting as an ICE when the automatic variable's context (function-local) conflicted with its use in a static context. Making the stash pointer file-static resolves this context discrepancy.
- ON SIZE ERROR clause
- A COBOL clause that specifies an action to be taken if an arithmetic or data movement operation results in a value that is too large to fit in the receiving field.
- Stash
- A temporary storage area used to hold data. In this context, it stores the original value of a destination variable before a potentially error-prone operation, allowing restoration if an ON SIZE ERROR occurs.
- ICE
- Internal Compiler Error. An unexpected condition encountered by the compiler during the translation of source code to machine code, usually indicating a bug in the compiler itself.
- File-static scope
- A variable scope that limits the visibility and lifetime of a variable to the specific source file in which it is defined. It persists throughout the program's execution but is only accessible within that file.
- Tree node
- In GCC, an internal representation of code or data structures. The compiler manipulates these nodes to perform optimizations and transformations. 'Static tree' refers to a tree node with a static lifetime.