aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-08-26 18:53:21 +0200
committerTristan Gingold <tgingold@free.fr>2020-08-26 22:39:04 +0200
commit91a073a2399321f42d63eaa53892eac68fc20257 (patch)
treec47baa1acab7d0dff94455070c2263e08ae804d0 /src
parent1f801a6f46a123544b2c0bc72fc11165618fa6af (diff)
downloadghdl-91a073a2399321f42d63eaa53892eac68fc20257.tar.gz
ghdl-91a073a2399321f42d63eaa53892eac68fc20257.tar.bz2
ghdl-91a073a2399321f42d63eaa53892eac68fc20257.zip
synth: handle evaluated string literals without constraints.
Fix #1430
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-expr.adb26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 60c8cd3d3..4d2dc7e95 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -665,6 +665,27 @@ package body Synth.Expr is
Len => Get_Range_Length (Rng));
end Synth_Bounds_From_Range;
+ function Synth_Bounds_From_Length (Atype : Node; Len : Int32)
+ return Bound_Type
+ is
+ Rng : constant Node := Get_Range_Constraint (Atype);
+ Limit : Int32;
+ begin
+ Limit := Int32 (Eval_Pos (Get_Left_Limit (Rng)));
+ case Get_Direction (Rng) is
+ when Dir_To =>
+ return (Dir => Dir_To,
+ Left => Limit,
+ Right => Limit + Len - 1,
+ Len => Uns32 (Len));
+ when Dir_Downto =>
+ return (Dir => Dir_Downto,
+ Left => Limit,
+ Right => Limit - Len + 1,
+ Len => Uns32 (Len));
+ end case;
+ end Synth_Bounds_From_Length;
+
function Synth_Simple_Aggregate (Syn_Inst : Synth_Instance_Acc;
Aggr : Node) return Valtyp
is
@@ -1766,8 +1787,9 @@ package body Synth.Expr is
when Type_Array =>
Bounds := Str_Typ.Abounds.D (1);
when Type_Unbounded_Vector
- | Type_Unbounded_Array =>
- Bounds := Synth_Array_Bounds (Syn_Inst, Str_Type, 1);
+ | Type_Unbounded_Array =>
+ Bounds := Synth_Bounds_From_Length
+ (Get_Index_Type (Str_Type, 0), Get_String_Length (Str));
when others =>
raise Internal_Error;
end case;