aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch6.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r--gcc/ada/sem_ch6.adb24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 5e365db..e75b00d 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -9754,6 +9754,30 @@ package body Sem_Ch6 is
Next_Formal (Formal);
end loop;
+
+ -- Special case: An equality function can be redefined for a type
+ -- occurring in a declarative part, and won't otherwise be treated as
+ -- a primitive because it doesn't occur in a package spec and doesn't
+ -- override an inherited subprogram. It's important that we mark it
+ -- primitive so it can be returned by Collect_Primitive_Operations
+ -- and be used in composing the equality operation of later types
+ -- that have a component of the type.
+
+ elsif Chars (S) = Name_Op_Eq
+ and then Etype (S) = Standard_Boolean
+ then
+ B_Typ := Base_Type (Etype (First_Formal (S)));
+
+ if Scope (B_Typ) = Current_Scope
+ and then
+ Base_Type (Etype (Next_Formal (First_Formal (S)))) = B_Typ
+ and then not Is_Limited_Type (B_Typ)
+ then
+ Is_Primitive := True;
+ Set_Is_Primitive (S);
+ Set_Has_Primitive_Operations (B_Typ);
+ Check_Private_Overriding (B_Typ);
+ end if;
end if;
end Check_For_Primitive_Subprogram;