https://gcc.gnu.org/g:f4261dc6161396b5b744e03fbae61bdd0e8c9924

commit r16-9003-gf4261dc6161396b5b744e03fbae61bdd0e8c9924
Author: Javier Miranda <[email protected]>
Date:   Wed Feb 25 18:08:37 2026 +0000

    ada: Crash on wrong renaming of record field
    
    gcc/ada/ChangeLog:
    
            * sem_ch8.adb (Find_Renamed_Entity): Protect call to First_Formal.

Diff:
---
 gcc/ada/sem_ch8.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 2aa3021cfa62..68537725e9bc 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -8167,7 +8167,8 @@ package body Sem_Ch8 is
                Old_S := Entity (Nam);
             end if;
 
-         elsif Present (First_Formal (Entity (Nam)))
+         elsif Can_Have_Formals (Entity (Nam))
+           and then Present (First_Formal (Entity (Nam)))
            and then Present (First_Formal (New_S))
            and then Base_Type (Etype (First_Formal (Entity (Nam)))) =
                     Base_Type (Etype (First_Formal (New_S)))

Reply via email to