[Ada] Fix access to predicated parent in Itype

Message ID 20210922151547.GA1907846@adacore.com
State Committed
Commit cbf1ffe1252430f0db0db18b0b695799bb31c242
Headers
Series [Ada] Fix access to predicated parent in Itype |

Commit Message

Pierre-Marie de Rodat Sept. 22, 2021, 3:15 p.m. UTC
  Getter function Predicated_Parent expects to be called on subtypes only,
which was not enforced always, possibly leading to assertion failures on
compiler built with assertions.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch13.adb (Build_Predicate_Functions): Access
	Predicated_Parent only on subtypes.
  

Patch

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -10191,6 +10191,9 @@  package body Sem_Ch13 is
         or else
           (Is_Itype (Typ)
            and then not Comes_From_Source (Typ)
+           and then Ekind (Typ) in E_Array_Subtype
+                                 | E_Record_Subtype
+                                 | E_Record_Subtype_With_Private
            and then Present (Predicated_Parent (Typ)))
       then
          return;