aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-04-23 08:50:53 +0200
committerTristan Gingold <tgingold@free.fr>2023-04-23 08:50:53 +0200
commite97e71f02c1571f18b01d88ae9069b31aab1f59e (patch)
treef985a1dd306f4a7b24ca579bdac799745692890f /src
parent5d31696367928825147750794386e055336f576e (diff)
downloadghdl-e97e71f02c1571f18b01d88ae9069b31aab1f59e.tar.gz
ghdl-e97e71f02c1571f18b01d88ae9069b31aab1f59e.tar.bz2
ghdl-e97e71f02c1571f18b01d88ae9069b31aab1f59e.zip
synth: check external names subtype
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-vhdl_expr.adb34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb
index 65e0a9d27..274548616 100644
--- a/src/synth/synth-vhdl_expr.adb
+++ b/src/synth/synth-vhdl_expr.adb
@@ -840,6 +840,7 @@ package body Synth.Vhdl_Expr is
Scope : constant Node := Get_Source_Scope (Cur_Inst);
Obj : Node;
Res : Valtyp;
+ Name_Typ : Type_Acc;
begin
-- Object simple name.
case Get_Kind (Scope) is
@@ -893,6 +894,9 @@ package body Synth.Vhdl_Expr is
(Loc_Inst, Path, "external name and object have different type");
return No_Valtyp;
end if;
+
+ Name_Typ := Synth_Subtype_Indication
+ (Loc_Inst, Get_Subtype_Indication (Name));
end;
-- LRM08 8.7 External names
@@ -912,7 +916,35 @@ package body Synth.Vhdl_Expr is
-- bounds and direction as the subtype of the object denoted by the
-- external name.
- -- TODO.
+ case Name_Typ.Kind is
+ when Type_Bit
+ | Type_Logic
+ | Type_Discrete =>
+ if Name_Typ.Drange /= Res.Typ.Drange then
+ Error_Msg_Synth
+ (Loc_Inst, Name, "bounds mismatch between name and object");
+ end if;
+ when Type_Float =>
+ if Name_Typ.Frange /= Res.Typ.Frange then
+ Error_Msg_Synth
+ (Loc_Inst, Name, "bounds mismatch between name and object");
+ end if;
+ when Type_Vector
+ | Type_Unbounded_Vector
+ | Type_Array
+ | Type_Array_Unbounded
+ | Type_Unbounded_Array
+ | Type_Unbounded_Record
+ | Type_Record =>
+ Res := Synth_Subtype_Conversion
+ (Loc_Inst, Res, Name_Typ, True, Name);
+ when Type_Protected
+ | Type_File
+ | Type_Access =>
+ null;
+ when Type_Slice =>
+ raise Internal_Error;
+ end case;
return Res;
end Synth_Pathname_Object;