]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix assertion failure on call in object notation in entry barrier
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 16 Mar 2026 07:08:05 +0000 (08:08 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 29 May 2026 08:49:47 +0000 (10:49 +0200)
The problem is that the Original_Record_Component field is accessed without
checking that it may be.

gcc/ada/ChangeLog:

* sem_util.adb (Statically_Names_Object) <N_Selected_Component>:
Return False if the selector is neither component nor discriminant.

gcc/ada/sem_util.adb

index 6d1647f96cd6771c786b967b52264953aa7dec95..625e93d443a0862d862090ab8e83d6246892bdf4 100644 (file)
@@ -29435,13 +29435,21 @@ package body Sem_Util is
                return False;
             end if;
 
+            --  Reject for example subprogram calls in object notation
+
+            if Ekind (Entity (Selector_Name (N))) not in E_Component
+                                                       | E_Discriminant
+            then
+               return False;
+            end if;
+
             declare
                Comp : constant Entity_Id :=
                  Original_Record_Component (Entity (Selector_Name (N)));
             begin
-              --  AI12-0373 confirms that we should not call
-              --  Has_Discriminant_Dependent_Constraint here which would be
-              --  too strong.
+               --  AI12-0373 confirms that we should not call
+               --  Has_Discriminant_Dependent_Constraint here,
+               --  which would be too strong.
 
                if Is_Declared_Within_Variant (Comp) then
                   return False;