From 2be57cd4116a65646f929f169ea96ca8c449cc5d Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 16 Apr 2020 18:22:59 +0200 Subject: synth: check for matching bounds in subtype conversions. --- src/synth/synth-expr.adb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index a256cbe09..5125e2ee8 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -717,6 +717,9 @@ package body Synth.Expr is -- Propagate error. return No_Valtyp; end if; + if Dtype = Vtype then + return Vt; + end if; case Dtype.Kind is when Type_Bit => @@ -786,7 +789,14 @@ package body Synth.Expr is return Vt; when Type_Array => pragma Assert (Vtype.Kind = Type_Array); - -- TODO: check bounds, handle elements + -- Check bounds. + for I in Vtype.Abounds.D'Range loop + if Vtype.Abounds.D (I).Len /= Dtype.Abounds.D (I).Len then + Error_Msg_Synth (+Loc, "mismatching array bounds"); + return No_Valtyp; + end if; + end loop; + -- TODO: check element. if Bounds then return Reshape_Value (Vt, Dtype); else -- cgit v1.2.3