diff options
author | Tristan Gingold | 2015-05-15 22:10:16 +0200 |
---|---|---|
committer | Tristan Gingold | 2015-05-15 22:10:16 +0200 |
commit | 9f074d32e6f7f57264442e0f8fc7cb058bd99b46 (patch) | |
tree | bf84c207120a10e4c07e8a749e39c8f8cf9229de | |
parent | f41084de955da1438542b2a3d42501077cdaa24e (diff) | |
download | ghdl-9f074d32e6f7f57264442e0f8fc7cb058bd99b46.tar.gz ghdl-9f074d32e6f7f57264442e0f8fc7cb058bd99b46.tar.bz2 ghdl-9f074d32e6f7f57264442e0f8fc7cb058bd99b46.zip |
type_conversion: use constraint_state instead of kind.
Fix ticket 66.
-rw-r--r-- | src/vhdl/evaluation.adb | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index ad464f7..27da938 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -1864,40 +1864,37 @@ package body Evaluation is begin -- The expression is either a simple aggregate or a (bit) string. Res := Build_Constant (Val, Conv); - case Get_Kind (Conv_Type) is - when Iir_Kind_Array_Subtype_Definition => - Set_Type (Res, Conv_Type); - if Eval_Discrete_Type_Length (Conv_Index_Type) - /= Eval_Discrete_Type_Length (Val_Index_Type) - then - Warning_Msg_Sem - ("non matching length in type conversion", Conv); - return Build_Overflow (Conv); - end if; - return Res; - when Iir_Kind_Array_Type_Definition => - if Get_Base_Type (Conv_Index_Type) = Get_Base_Type (Val_Index_Type) - then - Index_Type := Val_Index_Type; - else - -- Convert the index range. - -- It is an integer type. - Rng := Convert_Range (Get_Range_Constraint (Val_Index_Type), - Conv_Index_Type, Conv); - Index_Type := Create_Iir (Iir_Kind_Integer_Subtype_Definition); - Location_Copy (Index_Type, Conv); - Set_Range_Constraint (Index_Type, Rng); - Set_Base_Type (Index_Type, Get_Base_Type (Conv_Index_Type)); - Set_Type_Staticness (Index_Type, Locally); - end if; - Res_Type := Create_Unidim_Array_From_Index - (Get_Base_Type (Conv_Type), Index_Type, Conv); - Set_Type (Res, Res_Type); - Set_Type_Conversion_Subtype (Conv, Res_Type); - return Res; - when others => - Error_Kind ("eval_array_type_conversion", Conv_Type); - end case; + if Get_Constraint_State (Conv_Type) = Fully_Constrained then + Set_Type (Res, Conv_Type); + if Eval_Discrete_Type_Length (Conv_Index_Type) + /= Eval_Discrete_Type_Length (Val_Index_Type) + then + Warning_Msg_Sem + ("non matching length in type conversion", Conv); + return Build_Overflow (Conv); + end if; + return Res; + else + if Get_Base_Type (Conv_Index_Type) = Get_Base_Type (Val_Index_Type) + then + Index_Type := Val_Index_Type; + else + -- Convert the index range. + -- It is an integer type. + Rng := Convert_Range (Get_Range_Constraint (Val_Index_Type), + Conv_Index_Type, Conv); + Index_Type := Create_Iir (Iir_Kind_Integer_Subtype_Definition); + Location_Copy (Index_Type, Conv); + Set_Range_Constraint (Index_Type, Rng); + Set_Base_Type (Index_Type, Get_Base_Type (Conv_Index_Type)); + Set_Type_Staticness (Index_Type, Locally); + end if; + Res_Type := Create_Unidim_Array_From_Index + (Get_Base_Type (Conv_Type), Index_Type, Conv); + Set_Type (Res, Res_Type); + Set_Type_Conversion_Subtype (Conv, Res_Type); + return Res; + end if; end Eval_Array_Type_Conversion; function Eval_Type_Conversion (Expr : Iir) return Iir |