Ada: Centralize accessibility rule for conditional expressions
Implements Ada 3.10.2(9.1) accessibility rule for conditional expressions in a centralized manner, fixing anonymous access discriminant issues.
This commit centralizes the implementation of Ada’s rule 3.10.2(9.1) concerning the accessibility level of conditional expressions. Previously scattered and limited to specific contexts and anonymous access types, the new implementation handles both static and dynamic levels uniformly. This resolves issues with anonymous access discriminants and streamlines the accessibility checking process within the compiler.
In Details
This change refactors the GCC Ada front-end's accessibility analysis by centralizing the handling of rule 3.10.2(9.1) for conditional expressions. The Accessibility_Level unit now directly supports conditional expressions, incorporating both static and dynamic level computations. Obsolete code in sem_ch3.adb and sem_ch13.adb is removed, and sem_eval.adb is updated to use the new Choices_Match function for evaluating case expressions, improving uniformity and fixing issues with anonymous access types.
- Accessibility rule
- In Ada, a rule that ensures a pointer (access type) does not outlive the object it points to, preventing dangling pointers.
- Conditional expression
- An expression in Ada that evaluates to one of two values based on a condition, similar to a ternary operator in other languages.
- Anonymous access type
- An access type in Ada that is not explicitly declared with a name, often used for brevity.
- Discriminant
- A parameter of a variant record or access type in Ada that determines its structure or behavior.