]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Apply the check for all primitive equality operations
authorViljar Indus <indus@adacore.com>
Wed, 18 Feb 2026 09:29:23 +0000 (11:29 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 28 May 2026 08:52:45 +0000 (10:52 +0200)
gcc/ada/ChangeLog:

* sem_ch6.adb (Check_For_Primitive_Subprogram): add the
check for ghost equality functions for all branches handling
primitive subprograms.

gcc/ada/sem_ch6.adb

index 73ad8cf8d54ad99eaa211bc4102b03dfaae697cf..b0eeab5bdb6e3909deeeb35262df71d58c35923b 100644 (file)
@@ -11920,6 +11920,14 @@ package body Sem_Ch6 is
                   --  (SPARK RM 6.9(21)).
 
                   Check_Ghost_Primitive (S, B_Typ);
+
+                  --  A user-defined primitive equality operation on a
+                  --  non-ghost record type shall not be ghost, unless the
+                  --  record type has only limited views. (SPARK RM 6.9(23))
+
+                  if Chars (S) = Name_Op_Eq then
+                     Check_Ghost_Equality_Op (S, B_Typ);
+                  end if;
                end if;
             end if;
 
@@ -11961,6 +11969,14 @@ package body Sem_Ch6 is
                   --  (SPARK RM 6.9(21)).
 
                   Check_Ghost_Primitive (S, B_Typ);
+
+                  --  A user-defined primitive equality operation on a
+                  --  non-ghost record type shall not be ghost, unless the
+                  --  record type has only limited views. (SPARK RM 6.9(23))
+
+                  if Chars (S) = Name_Op_Eq then
+                     Check_Ghost_Equality_Op (S, B_Typ);
+                  end if;
                end if;
 
                Next_Formal (Formal);