]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix incorrect renaming of primitive subprogram in object notation
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 6 Nov 2025 19:03:49 +0000 (20:03 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 6 Nov 2025 19:16:46 +0000 (20:16 +0100)
commit9cc7722674877893d974b1e8018817ecba1e9acf
tree50a526d8f65a64ca0d7da8e78617a1fb514b8aca
parentd79d12d3faea6c4472ede35e4b66a68cf1f85f77
Ada: Fix incorrect renaming of primitive subprogram in object notation

It is possible to declare a subprogram renaming whose name is a primitive
subprogram in object notation; in this case, the name is unconditionally
evaluated in the front-end (unlike for objects) so that, if an ad-hoc body
needs to be built for the renaming later, the name is not reevaluated for
every call to it.

This evaluation is skipped if the name contains an implicit dereference,
as reported in the first PR, and the fix is to make the dereference explicit
at the end of the processing done in Analyze_Renamed_Primitive_Operation,
as is done in the sibling procedure Analyze_Renamed_Entry.  The patch also
makes a few consistency tweaks to them and also replaces a manual evaluation
of the name in Expand_N_Subprogram_Renaming_Declaration by a simple call to
Evaluate_Name, which is the procedure used for object renamings.

Analyze_Renamed_Primitive_Operation performs the resolution of the name
based on the declared profile, but it does not do that correctly in all
cases, as reported in the second PR; the fix is again straightforward.

gcc/ada/
PR ada/113350
PR ada/113551
* exp_ch2.adb (Expand_Renaming): Fix reference to Evaluate_Name.
* exp_ch8.adb (Expand_N_Subprogram_Renaming_Declaration): Call
Evaluate_Name to evaluate the name.
* sem_ch8.adb (Analyze_Renamed_Entry): Minor tweaks.
(Analyze_Renamed_Family_Member): Likewise.
(Analyze_Renamed_Primitive_Operation): Likewise.
Fix thinko in the function checking profile conformance, save the
result of the resolution and make implicit dereferences explicit.

gcc/testsuite
* gnat.dg/renaming19.adb: New test.
* gnat.dg/renaming19_pkg.ads: New helper.
* gnat.dg/renaming19_pkg.adb: Likewise.
gcc/ada/exp_ch2.adb
gcc/ada/exp_ch8.adb
gcc/ada/sem_ch8.adb
gcc/testsuite/gnat.dg/renaming19.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/renaming19_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/renaming19_pkg.ads [new file with mode: 0644]