aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2025-11-18 14:39:03 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-12-05 13:22:53 +0100
commitb85d7e3eecb616842a194dea799dfaa7db03366e (patch)
tree38ac522bbdc7dbac0970fa0dee34c8d8fd6e1ad1 /gcc
parentb6bfc77fe56ac999d515fe3899afbab0eb0ee480 (diff)
downloadgcc-b85d7e3eecb616842a194dea799dfaa7db03366e.zip
gcc-b85d7e3eecb616842a194dea799dfaa7db03366e.tar.gz
gcc-b85d7e3eecb616842a194dea799dfaa7db03366e.tar.bz2
ada: Fix false positive error for classwide containers
Get_Cursor_Type fails if a classwide container type is passed to it as it cannot correctly identify the cursor type since it is expecting the iteration functions to have a container argument with a classwide container type. gcc/ada/ChangeLog: * sem_util.adb (Get_Cursor_Type): use the specific type for classwide container checks.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_util.adb10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 123c79d..e4dd8db 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -10399,6 +10399,7 @@ package body Sem_Util is
Func : Entity_Id;
First_Op : Entity_Id;
Cursor : Entity_Id;
+ Specific_Type : Entity_Id := Typ;
begin
-- If error already detected, return
@@ -10407,6 +10408,10 @@ package body Sem_Util is
return Any_Type;
end if;
+ if Is_Class_Wide_Type (Specific_Type) then
+ Specific_Type := Etype (Typ);
+ end if;
+
-- The cursor type for an Iterable aspect is the return type of a
-- non-overloaded First primitive operation. Locate association for
-- First.
@@ -10437,12 +10442,13 @@ package body Sem_Util is
-- is created for it, check that the base type of the first formal
-- of First matches the base type of the domain.
- Func := First_Entity (Scope (Typ));
+ Func := First_Entity (Scope (Specific_Type));
while Present (Func) loop
if Chars (Func) = Chars (First_Op)
and then Ekind (Func) = E_Function
and then Present (First_Formal (Func))
- and then Base_Type (Etype (First_Formal (Func))) = Base_Type (Typ)
+ and then Base_Type (Etype (First_Formal (Func)))
+ = Base_Type (Specific_Type)
and then No (Next_Formal (First_Formal (Func)))
then
if Cursor /= Any_Type then