diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-12-25 07:14:21 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-12-26 15:09:25 +0100 |
commit | ab85386b440300ccec2ae19989cc604f754489da (patch) | |
tree | 0afb66de3f8226eedc8c053b8810fe46915d1354 /src/vhdl | |
parent | c202ca1c3cee382716b91911eca785465faf1c97 (diff) | |
download | ghdl-ab85386b440300ccec2ae19989cc604f754489da.tar.gz ghdl-ab85386b440300ccec2ae19989cc604f754489da.tar.bz2 ghdl-ab85386b440300ccec2ae19989cc604f754489da.zip |
vhdl08: check new 08 restrictions for file types.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/iirs.ads | 1 | ||||
-rw-r--r-- | src/vhdl/sem_types.adb | 59 |
2 files changed, 42 insertions, 18 deletions
diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index 065658e8b..e1a3021bb 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -2200,6 +2200,7 @@ package Iirs is -- -- Get/Set_Has_Signal_Flag (Flag3) -- + -- Always false. -- Get/Set_Index_Constraint_Flag (Flag4) -- Iir_Kind_Record_Type_Definition (Short) diff --git a/src/vhdl/sem_types.adb b/src/vhdl/sem_types.adb index 53d96229c..2576bb269 100644 --- a/src/vhdl/sem_types.adb +++ b/src/vhdl/sem_types.adb @@ -689,19 +689,19 @@ package body Sem_Types is Close_Declarative_Region; end Sem_Protected_Type_Body; - -- Return the constraint state from CONST (the initial state) and ATYPE, + -- Return the constraint state from CONST (the initial state) and EL_TYPE, -- as if ATYPE was a new element of a record. - function Update_Record_Constraint (Const : Iir_Constraint; Atype : Iir) + function Update_Record_Constraint (Const : Iir_Constraint; El_Type : Iir) return Iir_Constraint is begin - if Get_Kind (Atype) not in Iir_Kinds_Composite_Type_Definition then + if Get_Kind (El_Type) not in Iir_Kinds_Composite_Type_Definition then return Const; end if; case Const is when Fully_Constrained | Unconstrained => - if Get_Constraint_State (Atype) = Const then + if Get_Constraint_State (El_Type) = Const then return Const; else return Partially_Constrained; @@ -714,14 +714,12 @@ package body Sem_Types is function Get_Array_Constraint (Def : Iir) return Iir_Constraint is El_Type : constant Iir := Get_Element_Subtype (Def); - Index : constant Boolean := - Get_Kind (Def) = Iir_Kind_Array_Subtype_Definition - and then Get_Index_Constraint_Flag (Def); + Constrained_Index : constant Boolean := Get_Index_Constraint_Flag (Def); begin if Get_Kind (El_Type) in Iir_Kinds_Composite_Type_Definition then case Get_Constraint_State (El_Type) is when Fully_Constrained => - if Index then + if Constrained_Index then return Fully_Constrained; else return Partially_Constrained; @@ -729,14 +727,15 @@ package body Sem_Types is when Partially_Constrained => return Partially_Constrained; when Unconstrained => - if not Index then + if not Constrained_Index then return Unconstrained; else return Partially_Constrained; end if; end case; else - if Index then + -- Element subtype is not a composite subtype. + if Constrained_Index then return Fully_Constrained; else return Unconstrained; @@ -1097,14 +1096,38 @@ package body Sem_Types is -- If the base type is a composite type, it must not -- contain a subelement of an access type. Error_Msg_Sem (+Def, "%n cannot be a file type", +Type_Mark); - elsif Get_Kind (Type_Mark) in Iir_Kinds_Array_Type_Definition then - -- LRM 3.4 - -- If the base type is an array type, it must be a one - -- dimensional array type. - if not Is_One_Dimensional_Array_Type (Type_Mark) then - Error_Msg_Sem - (+Def, "multi-dimensional %n cannot be a file type", +Type_Mark); - end if; + else + -- LRM08 5.5 File type + -- If the base type is an array type, it shall be a one-dimensional + -- array type whose element subtype is fully constrained. If the + -- base type is a record type, it shall be fully constrained. + case Get_Kind (Type_Mark) is + when Iir_Kinds_Array_Type_Definition => + -- LRM 3.4 + -- If the base type is an array type, it must be a one + -- dimensional array type. + if not Is_One_Dimensional_Array_Type (Type_Mark) then + Error_Msg_Sem + (+Def, "multi-dimensional %n cannot be a file type", + +Type_Mark); + elsif not Is_Fully_Constrained_Type + (Get_Element_Subtype (Type_Mark)) + then + Error_Msg_Sem + (+Def, "element subtype of %n must be fully constrained", + +Type_Mark); + end if; + when Iir_Kind_Record_Type_Definition + | Iir_Kind_Record_Subtype_Definition => + if Get_Constraint_State (Type_Mark) /= Fully_Constrained then + Error_Msg_Sem + (+Def, "%n must be fully constrained", +Type_Mark); + end if; + when Iir_Kind_Interface_Type_Definition => + Error_Msg_Sem (+Def, "%n cannot be a file type", +Type_Mark); + when others => + null; + end case; end if; Set_Base_Type (Def, Def); |