diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-09-27 03:20:55 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-09-27 03:20:55 +0200 |
commit | 95f204711f04494ab56a63c656079a099fe98d9f (patch) | |
tree | 396c2895c3c8d6bfacdd18dac5647a2a5fa0fe0a /src | |
parent | f44b3c78755e01a9bd7fd9b639a08711b7c52660 (diff) | |
download | ghdl-95f204711f04494ab56a63c656079a099fe98d9f.tar.gz ghdl-95f204711f04494ab56a63c656079a099fe98d9f.tar.bz2 ghdl-95f204711f04494ab56a63c656079a099fe98d9f.zip |
Implement vhdl08 rules for #148
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/evaluation.ads | 8 | ||||
-rw-r--r-- | src/vhdl/sem_assocs.adb | 24 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/vhdl/evaluation.ads b/src/vhdl/evaluation.ads index 4d2bb218f..b4f145e70 100644 --- a/src/vhdl/evaluation.ads +++ b/src/vhdl/evaluation.ads @@ -100,7 +100,13 @@ package Evaluation is procedure Eval_Check_Range (A_Range : Iir; Sub_Type : Iir; Any_Dir : Boolean); - -- Return TRUE if range expression A_RANGE is not included in SUB_TYPE. + -- Return TRUE if A_RANGE is compatible with SUB_TYPE. Compatibility is + -- defined in LRM: + -- + -- LRM08 5.2 Scalar types + -- A range constraint is /compatible/ with a subtype if each bound of the + -- range belongs to the subtype or if the range constraint defines a null + -- range. function Eval_Is_Range_In_Bound (A_Range : Iir; Sub_Type : Iir; Any_Dir : Boolean) return Boolean; diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb index 19ba3de92..f1cb1fe85 100644 --- a/src/vhdl/sem_assocs.adb +++ b/src/vhdl/sem_assocs.adb @@ -454,6 +454,17 @@ package body Sem_Assocs is -- FIXME: non-static bounds have to be checked at run-time -- (during elaboration). + + -- In vhdl08, the subtypes must be compatible. Use the that rule + -- for 93c and relaxed rules. + if Vhdl_Std >= Vhdl_08 + or else Vhdl_Std = Vhdl_93c + or else Flag_Relaxed_Rules + then + return Eval_Is_Range_In_Bound (Src, Dest, True); + end if; + + -- Prior vhdl08, the subtypes must be identical. if not Eval_Is_Eq (Get_Left_Limit (Src_Range), Get_Left_Limit (Dst_Range)) or else not Eval_Is_Eq (Get_Right_Limit (Src_Range), @@ -482,6 +493,19 @@ package body Sem_Assocs is -- the subtype denoted by the subtype indication of the formal are not -- identical to the bounds and direction of the subtype denoted by the -- subtype indication of the actual. + + -- LRM08 14.3.5 Port map aspect + -- If an actual signal is associated with a port of mode IN or INOUT, + -- and if the type of the formal is a scalar type, then it is an error + -- if (after applying any conversion function or type conversion + -- expression present in the actual part) the subtype of the actual is + -- not compatible with the subtype of the formal. [...] + -- + -- Similarly, if an actual signal is associated with a port of mode + -- OUT, INOUT, or BUFFER, and the type of the actual is a scalar type, + -- then it is an error if (after applying any conversion function or + -- type conversion expression present in the formal part) the subtype + -- or the formal is not compatible with the subtype of the actual. if Is_Valid (F_Conv) then F2a_Type := Get_Type (F_Conv); else |