public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Constant_Indexing used when context requires a variable
@ 2023-11-30 10:18 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-11-30 10:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: Steve Baird

From: Steve Baird <baird@adacore.com>

In the case of a call with a formal parameter of mode other than "IN"
where the corresponding actual parameter is a generalized indexing
and the indexable container has both Constant_Indexing and Variable_Indexing
aspects specified, the generalized indexing must be interpreted as a
variable indexing, not as a constant indexing. In some cases involving a
call to a prefixed view of a subprogram, this was not handled correctly.
This error results in spurious compile-time error messages saying that
the actual parameter in the call "must be a variable".

gcc/ada/

	* sem_ch4.adb (Constant_Indexing_OK): As a temporary stopgap,
	return False in the case of an unanalyzed prefixed-view call.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch4.adb | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 83705b9dae1..d506944bc8d 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -8473,9 +8473,21 @@ package body Sem_Ch4 is
             --  resolution does not depend on the type of the parameter that
             --  includes the indexing operation.
 
-            elsif Nkind (Parent (Par)) in N_Subprogram_Call
-              and then Is_Entity_Name (Name (Parent (Par)))
-            then
+            elsif Nkind (Parent (Par)) in N_Subprogram_Call then
+
+               if not Is_Entity_Name (Name (Parent (Par))) then
+
+                  --  ??? We don't know what to do with an N_Selected_Component
+                  --  node for a prefixed-notation call to AA.BB where AA's
+                  --  type is known, but BB has not yet been resolved. In that
+                  --  case, the preceding Is_Entity_Name call returns False.
+                  --  Incorrectly returning False here will usually work
+                  --  better than incorrectly returning True, so that's what
+                  --  we do for now.
+
+                  return False;
+               end if;
+
                declare
                   Proc : Entity_Id;
 
-- 
2.42.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-30 10:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 10:18 [COMMITTED] ada: Constant_Indexing used when context requires a variable Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).