From 6739ef05016a6148f899be092a4e9bb4512d0d78 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 29 Mar 2020 08:28:33 +0200 Subject: synth: fix handling of subtype indication in object aliases for vhdl 2008. Fix #1175 --- src/synth/synth-decls.adb | 12 ++++++++---- src/vhdl/vhdl-annotations.adb | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index 263070ff4..704e6a65d 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -752,7 +752,7 @@ package body Synth.Decls is procedure Synth_Object_Alias_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Node) is - Atype : constant Node := Get_Type (Decl); + Atype : constant Node := Get_Declaration_Type (Decl); Obj : Value_Acc; Off : Uns32; Voff : Net; @@ -762,10 +762,12 @@ package body Synth.Decls is Obj_Type : Type_Acc; begin -- Subtype indication may not be present. - if Is_Anonymous_Type_Definition (Atype) then + if Atype /= Null_Node then Synth_Subtype_Indication (Syn_Inst, Atype); + Obj_Type := Get_Value_Type (Syn_Inst, Atype); + else + Obj_Type := null; end if; - Obj_Type := Get_Value_Type (Syn_Inst, Atype); Stmts.Synth_Assignment_Prefix (Syn_Inst, Get_Name (Decl), Obj, Off, Voff, Rdwd, Typ); @@ -778,7 +780,9 @@ package body Synth.Decls is else Res := Create_Value_Alias (Obj, Off, Typ); end if; - Res := Synth_Subtype_Conversion (Res, Obj_Type, True, Decl); + if Obj_Type /= null then + Res := Synth_Subtype_Conversion (Res, Obj_Type, True, Decl); + end if; Create_Object (Syn_Inst, Decl, Res); end Synth_Object_Alias_Declaration; diff --git a/src/vhdl/vhdl-annotations.adb b/src/vhdl/vhdl-annotations.adb index aef7cafc0..48ec93fc3 100644 --- a/src/vhdl/vhdl-annotations.adb +++ b/src/vhdl/vhdl-annotations.adb @@ -799,7 +799,10 @@ package body Vhdl.Annotations is Annotate_Subprogram_Body (Block_Info, Decl); when Iir_Kind_Object_Alias_Declaration => - Annotate_Anonymous_Type_Definition (Block_Info, Get_Type (Decl)); + if Get_Subtype_Indication (Decl) /= Null_Iir then + Annotate_Anonymous_Type_Definition + (Block_Info, Get_Type (Decl)); + end if; Create_Object_Info (Block_Info, Decl); when Iir_Kind_Non_Object_Alias_Declaration => -- cgit v1.2.3