]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix function call in object notation incorrectly rejected
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 6 Nov 2025 19:42:13 +0000 (20:42 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 6 Nov 2025 19:47:18 +0000 (20:47 +0100)
commit3dbca5ff67b830c2f0d512f048d0f334212a3191
treee4bb5aea1559ada4392e02a5e2f15f3bbc8af96a
parent1ae7073586dd7f2553885965994f6b76e8f42cd8
Ada: Fix function call in object notation incorrectly rejected

This happens in the name of a procedure call, again when there
is an implicit dereference in this name, and the fix to apply to
Find_Selected_Component is again straightforward:

--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -8524,9 +8524,7 @@ package body Sem_Ch8 is
          --  Error if the prefix is procedure or entry, as is P.X

          if Ekind (P_Name) /= E_Function
-           and then
-             (not Is_Overloaded (P)
-               or else Nkind (Parent (N)) = N_Procedure_Call_Statement)
+           and then not Is_Overloaded (P)
          then
             --  Prefix may mention a package that is hidden by a local
             --  declaration: let the user know. Scan the full homonym

But this also changes the diagnostics in illegal cases because they are not
uniform in the procedure, so the change also factors them out so as to make
them uniform, which slightly improves them in the end.

gcc/ada/
PR ada/113352
* sem_ch4.adb (Diagnose_Call): Tweak error message.
* sem_ch8.adb (Find_Selected_Component): Remove bypass for calls
to procedures in the overloaded overloadable case.  Factor out
the diagnostics code and invoke it uniformly in this case.

gcc/testsuite/
* gnat.dg/prefix3.adb: New test.
* gnat.dg/prefix3_pkg.ads: New helper.
* gnat.dg/prefix3_pkg.adb: Likewise.
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch8.adb
gcc/testsuite/gnat.dg/prefix3.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/prefix3_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/prefix3_pkg.ads [new file with mode: 0644]