From e8d6d5f039902653af5b04b58078bd1003acc624 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Wed, 9 Sep 2020 08:40:25 -0400 Subject: [PATCH] [Ada] Crash on membership test in expression function gcc/ada/ * freeze.adb (Freeze_Type_Refs): When an entity in an expression function is a type, freeze the entity and not just its type, which would be incomplete when the type is derived and/or tagged. --- gcc/ada/freeze.adb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index f3abba1..05a43c7 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7978,7 +7978,16 @@ package body Freeze is -- Check that a type referenced by an entity can be frozen if Is_Entity_Name (Node) and then Present (Entity (Node)) then - Check_And_Freeze_Type (Etype (Entity (Node))); + -- The entity itself may be a type, as in a membership test + -- or an attribute reference. Freezing its own type would be + -- incomplete if the entity is derived or an extension. + + if Is_Type (Entity (Node)) then + Check_And_Freeze_Type (Entity (Node)); + + else + Check_And_Freeze_Type (Etype (Entity (Node))); + end if; -- Check that the enclosing record type can be frozen -- 2.7.4