aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-08-05 19:03:01 +0200
committerTristan Gingold <tgingold@free.fr>2020-08-05 19:03:01 +0200
commitb2db06c1dcf66cd0751974551c61f96aab30c758 (patch)
tree35013d80d7925b1e1fdb61968be4ace5fb6f4d55 /src/vhdl
parent035eb113732f0c48b793e81301953d0e6ca6ba20 (diff)
downloadghdl-b2db06c1dcf66cd0751974551c61f96aab30c758.tar.gz
ghdl-b2db06c1dcf66cd0751974551c61f96aab30c758.tar.bz2
ghdl-b2db06c1dcf66cd0751974551c61f96aab30c758.zip
vhdl-sem_names: use element type of prefix type for indexed names.
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/vhdl-sem_names.adb25
-rw-r--r--src/vhdl/vhdl-sem_types.adb1
2 files changed, 16 insertions, 10 deletions
diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb
index 11333e1fd..24df8b789 100644
--- a/src/vhdl/vhdl-sem_names.adb
+++ b/src/vhdl/vhdl-sem_names.adb
@@ -2687,7 +2687,7 @@ package body Vhdl.Sem_Names is
function Sem_As_Indexed_Or_Slice_Name (Sub_Name : Iir; Finish : Boolean)
return Iir
is
- Base_Type : Iir;
+ Arr_Type : Iir;
Ptr_Type : Iir;
P : Iir;
R : Iir;
@@ -2713,21 +2713,26 @@ package body Vhdl.Sem_Names is
end if;
-- Extract type of prefix, handle possible implicit deference.
- Base_Type := Get_Base_Type (Get_Type (Sub_Name));
- if Get_Kind (Base_Type) = Iir_Kind_Access_Type_Definition then
- Ptr_Type := Base_Type;
- Base_Type := Get_Base_Type (Get_Designated_Type (Base_Type));
+ Arr_Type := Get_Type (Sub_Name);
+ if Kind_In (Arr_Type, Iir_Kind_Access_Type_Definition,
+ Iir_Kind_Access_Subtype_Definition)
+ then
+ -- FIXME: use base type until full support of access subtypes.
+ Ptr_Type := Get_Base_Type (Arr_Type);
+ Arr_Type := Get_Designated_Type (Arr_Type);
else
Ptr_Type := Null_Iir;
end if;
- if Get_Kind (Base_Type) /= Iir_Kind_Array_Type_Definition then
- if Finish and then not Is_Error (Base_Type) then
+ if not Kind_In (Arr_Type, Iir_Kind_Array_Type_Definition,
+ Iir_Kind_Array_Subtype_Definition)
+ then
+ if Finish and then not Is_Error (Arr_Type) then
Error_Msg_Sem (+Name, "type of prefix is not an array");
end if;
return Null_Iir;
end if;
- if Get_Nbr_Elements (Get_Index_Subtype_List (Base_Type)) /=
+ if Get_Nbr_Elements (Get_Index_Subtype_List (Arr_Type)) /=
Get_Chain_Length (Assoc_Chain)
then
if Finish then
@@ -2743,7 +2748,7 @@ package body Vhdl.Sem_Names is
if Slice_Index_Kind = Iir_Kind_Indexed_Name and then not Finish then
declare
Type_Index_List : constant Iir_Flist :=
- Get_Index_Subtype_List (Base_Type);
+ Get_Index_Subtype_List (Arr_Type);
Type_Index : Iir;
Assoc : Iir;
begin
@@ -2800,7 +2805,7 @@ package body Vhdl.Sem_Names is
end loop;
Set_Index_List (R, List_To_Flist (Idx_List));
end;
- Set_Type (R, Get_Element_Subtype (Base_Type));
+ Set_Type (R, Get_Element_Subtype (Arr_Type));
when others =>
raise Internal_Error;
end case;
diff --git a/src/vhdl/vhdl-sem_types.adb b/src/vhdl/vhdl-sem_types.adb
index 969be9471..95f48d71e 100644
--- a/src/vhdl/vhdl-sem_types.adb
+++ b/src/vhdl/vhdl-sem_types.adb
@@ -2315,6 +2315,7 @@ package body Vhdl.Sem_Types is
Location_Copy (Res, Def);
Set_Parent_Type (Res, Type_Mark);
Set_Designated_Subtype_Indication (Res, Sub_Type);
+ Set_Designated_Type (Res, Sub_Type);
Set_Signal_Type_Flag (Res, False);
-- The type_mark is a type_mark of the access subtype,