Fix Ada generic instance resolution for aggregate expressions
Corrects incorrect name resolution for aggregate expressions within generic Ada instances.
A regression in the Ada front-end caused global names within the expression of an iterated component association in an aggregate to be resolved incorrectly when used in a generic unit instance. This fix ensures that these expressions are correctly resolved by making a copy of the expression tree using New_Copy_Tree during the resolution process. A new test case has been added to verify the fix.
In Details
In Ada's semantic analysis, resolving expressions within aggregate component associations (especially iterated ones) in generic unit instances has been problematic. This patch fixes PRs ada/128723 and ada/129058 by ensuring that the expression tree of the iterated component association is properly copied (New_Copy_Tree) when resolving it within a generic instance. Previously, global names in such expressions could be resolved in the generic unit's scope and then incorrectly dropped or re-resolved in the instance's scope.
- Ada
- A high-level, structured, statically and strongly typed programming language, designed for large, long-lived applications where reliability and efficiency are crucial.
- Generic unit
- In Ada, a template or blueprint for a type, subroutine, or package that can be parameterized, allowing for code reuse similar to C++ templates or Java generics.
- Aggregate
- In Ada, a construct used to represent an array or record value. It consists of a list of component associations, specifying values for components.
- Component association
- A pair of a component name (or range) and its corresponding value within an aggregate in Ada.
- Iterated component association
- A specific type of component association in Ada aggregates that uses an expression to initialize multiple components, often for arrays.
- Semantic analysis
- A phase in a compiler's frontend that checks the meaning and consistency of the program's structure, including type checking, name resolution, and verifying language rules.