Ada: Fix bogus warning on use clause for package
Removes a spurious warning related to Ada package use clauses and local renamings.
A bogus warning was issued in the Ada compiler when an overloaded subprogram from a package was locally renamed. This occurred because the renaming was not correctly recorded as a reference to the package itself. The fix involves passing the correct entity name to Find_Renamed_Entity and ensuring that use clauses are marked even in overloaded scenarios.
In Details
In GCC's Ada semantic analyzer (sem_ch8.adb), a warning related to use clauses was incorrectly triggered when an overloaded subprogram within a package was locally renamed. The issue stemmed from Find_Renamed_Entity not properly recording the reference to the parent package when resolving overloaded names. This commit corrects Analyze_Subprogram_Renaming to pass the Nam (name) instead of Name (N) to Find_Renamed_Entity, and Find_Renamed_Entity now calls Mark_Use_Clauses for the resolved overloaded entity.
- use clause
- In Ada, a
useclause makes types, subtypes, objects, and subprograms from a package directly accessible without needing to qualify them with the package name. - overloaded subprogram
- A subprogram (function or procedure) that has the same name as another subprogram but differs in its parameter list or return type, allowing multiple subprograms to share a name.
- renaming
- In Ada, an entity (like a subprogram or object) can be given a new name, which can be used as an alias or to simplify access.
- semantic analyzer
- A phase in a compiler that checks the meaning and consistency of a program's syntax, ensuring that it follows the language's rules beyond just grammatical correctness (e.g., type checking, scope resolution).
- Ada package
- A collection of related declarations (types, objects, subprograms) in Ada, used for modularity and information hiding, similar to namespaces or modules in other languages.