diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-11-05 17:38:20 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-11-05 17:38:20 +0100 |
commit | 0008064ba19607fa57301864c601e4f0038979f0 (patch) | |
tree | e16378900389a4c9e7ad0bf211f334c19aad56c8 /src/vhdl | |
parent | ab5e10334eb99b96f221d9c54474557b496ea841 (diff) | |
download | ghdl-0008064ba19607fa57301864c601e4f0038979f0.tar.gz ghdl-0008064ba19607fa57301864c601e4f0038979f0.tar.bz2 ghdl-0008064ba19607fa57301864c601e4f0038979f0.zip |
Are_Bounds_Locally_Static: add comment, do what it is described.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/iirs_utils.adb | 69 | ||||
-rw-r--r-- | src/vhdl/iirs_utils.ads | 2 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 1 |
3 files changed, 37 insertions, 35 deletions
diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb index a61c68eb2..b98961e91 100644 --- a/src/vhdl/iirs_utils.adb +++ b/src/vhdl/iirs_utils.adb @@ -1079,53 +1079,52 @@ package body Iirs_Utils is return True; end Are_Array_Indexes_Locally_Static; - -- Return true if array/record bounds are locally static. - function Are_Bounds_Locally_Static (Def : Iir) return Boolean - is - pragma Assert (Get_Constraint_State (Def) = Fully_Constrained); + function Are_Bounds_Locally_Static (Def : Iir) return Boolean is begin - case Get_Kind (Def) is + if Get_Type_Staticness (Def) = Locally then + return True; + end if; + + case Iir_Kinds_Type_And_Subtype_Definition (Get_Kind (Def)) is when Iir_Kind_Array_Subtype_Definition => - declare - El_Btype : Iir; - begin - -- Indexes. - if not Are_Array_Indexes_Locally_Static (Def) then - return False; - end if; + pragma Assert (Get_Constraint_State (Def) = Fully_Constrained); + + -- Indexes. + if not Are_Array_Indexes_Locally_Static (Def) then + return False; + end if; + + -- Element. + return Are_Bounds_Locally_Static (Get_Element_Subtype (Def)); + when Iir_Kind_Array_Type_Definition => + return False; + when Iir_Kind_Record_Subtype_Definition + | Iir_Kind_Record_Type_Definition => + pragma Assert (Get_Constraint_State (Def) = Fully_Constrained); - -- Element. - El_Btype := Get_Element_Subtype (Get_Base_Type (Def)); - if not Is_Fully_Constrained_Type (El_Btype) then - return Are_Bounds_Locally_Static (Get_Element_Subtype (Def)); - else - -- Element was fully constrained. - return True; - end if; - end; - when Iir_Kind_Record_Subtype_Definition => declare - Base_Type : constant Iir := Get_Base_Type (Def); El_List : constant Iir_List := Get_Elements_Declaration_List (Def); - El_Blist : constant Iir_List := - Get_Elements_Declaration_List (Base_Type); - El, Bel : Iir; + El : Iir; begin for I in Natural loop - Bel := Get_Nth_Element (El_Blist, I); - exit when Bel = Null_Iir; - if not Is_Fully_Constrained_Type (Get_Type (Bel)) then - El := Get_Nth_Element (El_List, I); - if not Are_Bounds_Locally_Static (Get_Type (El)) then - return False; - end if; + El := Get_Nth_Element (El_List, I); + exit when El = Null_Iir; + if not Are_Bounds_Locally_Static (Get_Type (El)) then + return False; end if; end loop; return True; end; - when others => - Error_Kind ("get_bounds_staticness", Def); + when Iir_Kinds_Scalar_Type_And_Subtype_Definition + | Iir_Kind_Protected_Type_Declaration + | Iir_Kind_Access_Type_Definition + | Iir_Kind_Access_Subtype_Definition => + return True; + when Iir_Kind_Incomplete_Type_Definition + | Iir_Kind_File_Type_Definition + | Iir_Kind_Interface_Type_Definition => + Error_Kind ("are_bounds_locally_static", Def); end case; end Are_Bounds_Locally_Static; diff --git a/src/vhdl/iirs_utils.ads b/src/vhdl/iirs_utils.ads index 02ed90b22..43cda1d1a 100644 --- a/src/vhdl/iirs_utils.ads +++ b/src/vhdl/iirs_utils.ads @@ -232,6 +232,8 @@ package Iirs_Utils is -- Return true if array/record bounds are locally static. Only fully -- constrained records or arrays are allowed. + -- It is possible to have non-locally static types with locally bounds (eg: + -- a constrained array of type). function Are_Bounds_Locally_Static (Def : Iir) return Boolean; -- Return the type or subtype definition of the SUBTYP type mark. diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 4819083a8..e5ba9a1ee 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -719,6 +719,7 @@ package body Trans.Chap3 is (Create_Identifier ("STB"), Base_Info.B.Bounds_Type, Global_Storage, Val); else + pragma Assert (Get_Type_Staticness (Def) /= Locally); Info.S.Static_Bounds := False; Info.S.Composite_Bounds := Create_Var (Create_Var_Identifier ("STB"), Base_Info.B.Bounds_Type); |