aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2024-11-21 15:32:47 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-12-12 10:58:01 +0100
commitbbcf4d2ab6f4d4e97605a2754051fd53c9fb22c2 (patch)
tree21a567b175aadc0533c44d5d8cec8cb9300ca8fa /gcc
parent07fe98fb1a92944eab83c4254e55f5bfee916a0b (diff)
downloadgcc-bbcf4d2ab6f4d4e97605a2754051fd53c9fb22c2.zip
gcc-bbcf4d2ab6f4d4e97605a2754051fd53c9fb22c2.tar.gz
gcc-bbcf4d2ab6f4d4e97605a2754051fd53c9fb22c2.tar.bz2
ada: Defend against risk of infinite loop
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch3.adb4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 11f69db..5df949a 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -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);