]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash on selected component lookup in generic instance
authorBob Duff <duff@adacore.com>
Wed, 23 Aug 2023 12:14:07 +0000 (08:14 -0400)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:15 +0000 (13:05 +0200)
This patch fixes a compiler crash on selected component lookup in an instance
of a generic unit when the relevant type is an itype.

gcc/ada/

* sem_ch4.adb (Find_Component_In_Instance): Check that
Declaration_Node (Par) is not Empty, as it is for itypes.

gcc/ada/sem_ch4.adb

index 8543f0d578bc9df6d0855dd8d353b908962ddfd6..50ba6c9c847c408e66298159b91ec50baed43d02 100644 (file)
@@ -5212,10 +5212,14 @@ package body Sem_Ch4 is
             end if;
          end loop;
 
-         if Present (Par) and then Is_Generic_Actual_Type (Par) then
-
-            --  Now look for component in ancestor types
+         --  If Par is a generic actual, look for component in ancestor types.
+         --  Skip this if we have no Declaration_Node, as is the case for
+         --  itypes.
 
+         if Present (Par)
+           and then Is_Generic_Actual_Type (Par)
+           and then Present (Declaration_Node (Par))
+         then
             Par := Generic_Parent_Type (Declaration_Node (Par));
             loop
                Find_Component_In_Instance (Par);