llvm-project
32932727 - [flang][semantics] Reject DATA-style initializer on EXTERNAL/INTRINSIC (#222256)

Commit
43 days ago
[flang][semantics] Reject DATA-style initializer on EXTERNAL/INTRINSIC (#222256) An `entity-decl` carrying a legacy `/initialization/` (an extension) was silently accepted, and the initializer dropped, when the name had already been declared `EXTERNAL` or `INTRINSIC`: ```fortran subroutine s external foo integer foo /1/ ! accepted, no initialization emitted end subroutine ``` `DataChecker::Leave(const parser::EntityDecl &)` passed the value list to `AccumulateDataInitializations` without checking the symbol's class, so the initialization never reached the emitted code and no diagnostic was produced. Reversing the two statements already errors, so the behaviour was also order-dependent. For an intrinsic name that is not an unrestricted specific function (`sum`), the accumulated value instead tripped `CHECK(designator.has_value())` in `data-to-inits.cpp` and crashed the compiler. A procedure name is not a data-stmt-object (F2023 C880, R842), so reject it here. Procedure pointer initialization is an accepted extension (8.6.7), so `IsProcedurePointer` symbols still take the existing path. Fixes #222168 Assisted-by: Qoder (AI assistant)
Author
Parents
Loading