Ada: Fix missing error on illegal use of access-to-subprogram parameter
Enforces compile-time errors for invalid access-to-subprogram parameter usage in Ada.
This commit addresses an oversight in GCC’s Ada compiler where illegal uses of access-to-subprogram parameters were not always caught at compile time. Specifically, it now correctly rejects cases where such parameters are reused as named access-to-subprogram values, enforcing Ada Reference Manual rules regarding accessibility levels. New test cases have been added to verify this fix.
In Details
The Ada semantic analyzer in GCC (sem_ch5.adb and sem_res.adb) previously failed to enforce the strict accessibility rules (RM 3.10.2(13.1)) for access-to-subprogram types used as parameters. While assignments were correctly checked, other contexts allowing reuse of these parameters as named values of the same type were not. This patch adds checks in Resolve and modifies Valid_Conversion to ensure that an anonymous access-to-subprogram type on the RHS of an assignment does not lead to an implicit conversion, thereby catching illegal reuse of such access parameters, particularly in Ada…
- access-to-subprogram type
- An Ada pointer type that points to a subprogram (function or procedure).
- accessibility level
- A concept in Ada that governs the lifetime and validity of access types, ensuring that an access value does not outlive the object it points to.
- RM
- Reference Manual, referring to the official language specification for Ada.