cobol: Report CALL with dynamic target
New warning option `-Wdynamic-call` flags COBOL CALL statements with runtime-resolved targets.
GCC’s COBOL front-end now supports a new warning option, -Wdynamic-call. This option flags CALL statements where the target is not a constant symbol, meaning the call will be resolved at runtime. This provides developers with better visibility into dynamic call behavior, which can be important for performance and debugging. Constant targets are exported as symbols for standard linker resolution.
In Details
The COBOL compiler now supports the -Wdynamic-call option. When enabled, it diagnoses CALL statements where the target is not a compile-time constant. Such calls require runtime resolution by the dynamic linker. The compiler emits a diagnostic note for each such call, aiding developers in identifying and potentially optimizing or verifying dynamic call sites. Constant targets are handled through standard symbol export for static linking.
- CALL statement
- A COBOL statement used to invoke a subroutine or another program. The target of the CALL can be a literal program name or a variable containing the program name.
- dynamic target
- In the context of a CALL statement, a target whose name is not known at compile time and is determined during program execution, often through a variable or data structure.
- symbol
- A named identifier used by the linker to refer to a function, variable, or other program section. Symbols allow different parts of a program, or different programs, to be linked together.