]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Defend against risk of infinite loop
authorRonan Desplanques <desplanques@adacore.com>
Thu, 21 Nov 2024 14:32:47 +0000 (15:32 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:58:01 +0000 (10:58 +0100)
A recently fixed bug caused an infinite loop when assertions were not
checked. With assertions checked, the symptom was just an internal
error caused by an assertion failure. This patch makes it so that if
another bug ever causes the same condition to fail, there will never be
an infinite loop with any assertion policy.

gcc/ada/ChangeLog:

* sem_ch3.adb (Access_Subprogram_Declaration): Replace assertion with
more defensive code.

gcc/ada/sem_ch3.adb

index 11f69db21dc2b6873122fbbbd76f04df342d5ce3..5df949aa6673703fbb0ac4b29d9567877659a645 100644 (file)
@@ -1100,7 +1100,9 @@ package body Sem_Ch3 is
                                 | N_Protected_Type_Declaration
       loop
          D_Ityp := Parent (D_Ityp);
-         pragma Assert (D_Ityp /= Empty);
+         if No (D_Ityp) then
+            raise Program_Error;
+         end if;
       end loop;
 
       Set_Associated_Node_For_Itype (Desig_Type, D_Ityp);