In Ada 2022 mode, the compiler crashes when generating the Put_Image
function for a tagged type if the parent subtype is constrained.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* exp_put_image.adb (Make_Component_Attributes): Use
Implementation_Base_Type to get the parent type. Otherwise,
Parent_Type_Decl is actually an internally generated subtype
declaration, so we blow up on
Type_Definition (Parent_Type_Decl).
diff --git a/gcc/ada/exp_put_image.adb b/gcc/ada/exp_put_image.adb
--- a/gcc/ada/exp_put_image.adb
+++ b/gcc/ada/exp_put_image.adb
@@ -658,8 +658,8 @@ package body Exp_Put_Image is
if Chars (Defining_Identifier (Item)) = Name_uParent then
declare
Parent_Type : constant Entity_Id :=
- Underlying_Type (Base_Type (
- (Etype (Defining_Identifier (Item)))));
+ Implementation_Base_Type
+ (Etype (Defining_Identifier (Item)));
Parent_Aspect_Spec : constant Node_Id :=
Find_Aspect (Parent_Type, Aspect_Put_Image);