diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-03-04 07:58:28 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-03-04 07:58:28 +0100 |
commit | 7356d30f26ec213b8e342e2b17a67443b0452801 (patch) | |
tree | 2c37e80dfa48bc224b9ce486dc98f958b464301e /src/vhdl | |
parent | caad9e78229b7c3cffb0e4f401a2a20179783b91 (diff) | |
download | ghdl-7356d30f26ec213b8e342e2b17a67443b0452801.tar.gz ghdl-7356d30f26ec213b8e342e2b17a67443b0452801.tar.bz2 ghdl-7356d30f26ec213b8e342e2b17a67443b0452801.zip |
vhdl: parse return identifier (v19)
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 16 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 7 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 438 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 31 |
5 files changed, 284 insertions, 210 deletions
diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 94c01f275..947cd771d 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -3711,6 +3711,22 @@ package body Vhdl.Nodes is Set_Field3 (Target, Name_Id_To_Iir (Label)); end Set_Label; + function Get_Return_Identifier (Target : Iir) return Iir is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Return_Identifier (Get_Kind (Target)), + "no field Return_Identifier"); + return Get_Field11 (Target); + end Get_Return_Identifier; + + procedure Set_Return_Identifier (Target : Iir; Decl : Iir) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Return_Identifier (Get_Kind (Target)), + "no field Return_Identifier"); + Set_Field11 (Target, Decl); + end Set_Return_Identifier; + function Get_Visible_Flag (Target : Iir) return Boolean is begin pragma Assert (Target /= Null_Iir); diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index a36566a5c..aac961bb6 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -1606,6 +1606,8 @@ package Vhdl.Nodes is -- -- Get/Set_Subprogram_Depth (Field10) -- + -- Get/Set_Return_Identifier (Field11) + -- -- Get/Set_Overload_Number (Field12) -- -- Get/Set_Seen_Flag (Flag1) @@ -8183,6 +8185,11 @@ package Vhdl.Nodes is function Get_Label (Target : Iir) return Name_Id; procedure Set_Label (Target : Iir; Label : Name_Id); + -- Return a subtype declaration for the return subtype (vhdl-19) + -- Field: Field11 + function Get_Return_Identifier (Target : Iir) return Iir; + procedure Set_Return_Identifier (Target : Iir; Decl : Iir); + -- Get/Set the visible flag of a declaration. -- The visible flag is true to make invalid the use of the identifier -- during its declaration. It is set to false when the identifier is added diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index 53eceebd9..f08c00504 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -161,6 +161,7 @@ package body Vhdl.Nodes_Meta is Field_Primary_Unit => Type_Iir, Field_Identifier => Type_Name_Id, Field_Label => Type_Name_Id, + Field_Return_Identifier => Type_Iir, Field_Visible_Flag => Type_Boolean, Field_Range_Constraint => Type_Iir, Field_Direction => Type_Direction_Type, @@ -687,6 +688,8 @@ package body Vhdl.Nodes_Meta is return "identifier"; when Field_Label => return "label"; + when Field_Return_Identifier => + return "return_identifier"; when Field_Visible_Flag => return "visible_flag"; when Field_Range_Constraint => @@ -2083,6 +2086,8 @@ package body Vhdl.Nodes_Meta is return Attr_None; when Field_Label => return Attr_None; + when Field_Return_Identifier => + return Attr_None; when Field_Visible_Flag => return Attr_None; when Field_Range_Constraint => @@ -3485,6 +3490,7 @@ package body Vhdl.Nodes_Meta is Field_Generic_Chain, Field_Return_Type_Mark, Field_Subprogram_Body, + Field_Return_Identifier, -- Iir_Kind_Procedure_Declaration Field_Subprogram_Depth, Field_Overload_Number, @@ -3510,6 +3516,7 @@ package body Vhdl.Nodes_Meta is Field_Generic_Chain, Field_Return_Type_Mark, Field_Subprogram_Body, + Field_Return_Identifier, -- Iir_Kind_Function_Body Field_Impure_Depth, Field_End_Has_Reserved_Id, @@ -5364,214 +5371,214 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Psl_Declaration => 776, Iir_Kind_Psl_Endpoint_Declaration => 790, Iir_Kind_Enumeration_Literal => 802, - Iir_Kind_Function_Declaration => 827, - Iir_Kind_Procedure_Declaration => 851, - Iir_Kind_Function_Body => 861, - Iir_Kind_Procedure_Body => 872, - Iir_Kind_Function_Instantiation_Declaration => 883, - Iir_Kind_Procedure_Instantiation_Declaration => 893, - Iir_Kind_Terminal_Declaration => 902, - Iir_Kind_Object_Alias_Declaration => 914, - Iir_Kind_Free_Quantity_Declaration => 926, - Iir_Kind_Spectrum_Quantity_Declaration => 939, - Iir_Kind_Noise_Quantity_Declaration => 951, - Iir_Kind_Across_Quantity_Declaration => 967, - Iir_Kind_Through_Quantity_Declaration => 983, - Iir_Kind_File_Declaration => 998, - Iir_Kind_Guard_Signal_Declaration => 1012, - Iir_Kind_Signal_Declaration => 1029, - Iir_Kind_Variable_Declaration => 1042, - Iir_Kind_Constant_Declaration => 1056, - Iir_Kind_Iterator_Declaration => 1068, - Iir_Kind_Interface_Constant_Declaration => 1085, - Iir_Kind_Interface_Variable_Declaration => 1101, - Iir_Kind_Interface_Signal_Declaration => 1122, - Iir_Kind_Interface_File_Declaration => 1138, - Iir_Kind_Interface_Quantity_Declaration => 1154, - Iir_Kind_Interface_Terminal_Declaration => 1166, - Iir_Kind_Interface_Type_Declaration => 1177, - Iir_Kind_Interface_Package_Declaration => 1190, - Iir_Kind_Interface_Function_Declaration => 1208, - Iir_Kind_Interface_Procedure_Declaration => 1222, - Iir_Kind_Signal_Attribute_Declaration => 1225, - Iir_Kind_Identity_Operator => 1229, - Iir_Kind_Negation_Operator => 1233, - Iir_Kind_Absolute_Operator => 1237, - Iir_Kind_Not_Operator => 1241, - Iir_Kind_Implicit_Condition_Operator => 1245, - Iir_Kind_Condition_Operator => 1249, - Iir_Kind_Reduction_And_Operator => 1253, - Iir_Kind_Reduction_Or_Operator => 1257, - Iir_Kind_Reduction_Nand_Operator => 1261, - Iir_Kind_Reduction_Nor_Operator => 1265, - Iir_Kind_Reduction_Xor_Operator => 1269, - Iir_Kind_Reduction_Xnor_Operator => 1273, - Iir_Kind_And_Operator => 1278, - Iir_Kind_Or_Operator => 1283, - Iir_Kind_Nand_Operator => 1288, - Iir_Kind_Nor_Operator => 1293, - Iir_Kind_Xor_Operator => 1298, - Iir_Kind_Xnor_Operator => 1303, - Iir_Kind_Equality_Operator => 1308, - Iir_Kind_Inequality_Operator => 1313, - Iir_Kind_Less_Than_Operator => 1318, - Iir_Kind_Less_Than_Or_Equal_Operator => 1323, - Iir_Kind_Greater_Than_Operator => 1328, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1333, - Iir_Kind_Match_Equality_Operator => 1338, - Iir_Kind_Match_Inequality_Operator => 1343, - Iir_Kind_Match_Less_Than_Operator => 1348, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1353, - Iir_Kind_Match_Greater_Than_Operator => 1358, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1363, - Iir_Kind_Sll_Operator => 1368, - Iir_Kind_Sla_Operator => 1373, - Iir_Kind_Srl_Operator => 1378, - Iir_Kind_Sra_Operator => 1383, - Iir_Kind_Rol_Operator => 1388, - Iir_Kind_Ror_Operator => 1393, - Iir_Kind_Addition_Operator => 1398, - Iir_Kind_Substraction_Operator => 1403, - Iir_Kind_Concatenation_Operator => 1408, - Iir_Kind_Multiplication_Operator => 1413, - Iir_Kind_Division_Operator => 1418, - Iir_Kind_Modulus_Operator => 1423, - Iir_Kind_Remainder_Operator => 1428, - Iir_Kind_Exponentiation_Operator => 1433, - Iir_Kind_Function_Call => 1441, - Iir_Kind_Aggregate => 1448, - Iir_Kind_Parenthesis_Expression => 1451, - Iir_Kind_Qualified_Expression => 1455, - Iir_Kind_Type_Conversion => 1460, - Iir_Kind_Allocator_By_Expression => 1465, - Iir_Kind_Allocator_By_Subtype => 1471, - Iir_Kind_Selected_Element => 1479, - Iir_Kind_Dereference => 1484, - Iir_Kind_Implicit_Dereference => 1489, - Iir_Kind_Slice_Name => 1496, - Iir_Kind_Indexed_Name => 1502, - Iir_Kind_Psl_Prev => 1508, - Iir_Kind_Psl_Stable => 1513, - Iir_Kind_Psl_Rose => 1518, - Iir_Kind_Psl_Fell => 1523, - Iir_Kind_Psl_Onehot => 1526, - Iir_Kind_Psl_Onehot0 => 1529, - Iir_Kind_Psl_Expression => 1531, - Iir_Kind_Sensitized_Process_Statement => 1552, - Iir_Kind_Process_Statement => 1572, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1585, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1598, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1612, - Iir_Kind_Concurrent_Assertion_Statement => 1620, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1627, - Iir_Kind_Concurrent_Break_Statement => 1635, - Iir_Kind_Psl_Assert_Directive => 1649, - Iir_Kind_Psl_Assume_Directive => 1661, - Iir_Kind_Psl_Cover_Directive => 1673, - Iir_Kind_Psl_Restrict_Directive => 1684, - Iir_Kind_Block_Statement => 1698, - Iir_Kind_If_Generate_Statement => 1709, - Iir_Kind_Case_Generate_Statement => 1718, - Iir_Kind_For_Generate_Statement => 1727, - Iir_Kind_Component_Instantiation_Statement => 1738, - Iir_Kind_Psl_Default_Clock => 1741, - Iir_Kind_Generate_Statement_Body => 1752, - Iir_Kind_If_Generate_Else_Clause => 1758, - Iir_Kind_Simple_Simultaneous_Statement => 1765, - Iir_Kind_Simultaneous_Null_Statement => 1769, - Iir_Kind_Simultaneous_Procedural_Statement => 1780, - Iir_Kind_Simultaneous_Case_Statement => 1789, - Iir_Kind_Simultaneous_If_Statement => 1798, - Iir_Kind_Simultaneous_Elsif => 1804, - Iir_Kind_Simple_Signal_Assignment_Statement => 1815, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1826, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1838, - Iir_Kind_Signal_Force_Assignment_Statement => 1848, - Iir_Kind_Signal_Release_Assignment_Statement => 1857, - Iir_Kind_Null_Statement => 1861, - Iir_Kind_Assertion_Statement => 1868, - Iir_Kind_Report_Statement => 1874, - Iir_Kind_Wait_Statement => 1882, - Iir_Kind_Variable_Assignment_Statement => 1889, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1896, - Iir_Kind_Return_Statement => 1902, - Iir_Kind_For_Loop_Statement => 1913, - Iir_Kind_While_Loop_Statement => 1924, - Iir_Kind_Next_Statement => 1931, - Iir_Kind_Exit_Statement => 1938, - Iir_Kind_Case_Statement => 1947, - Iir_Kind_Procedure_Call_Statement => 1953, - Iir_Kind_Break_Statement => 1960, - Iir_Kind_If_Statement => 1970, - Iir_Kind_Elsif => 1976, - Iir_Kind_Character_Literal => 1983, - Iir_Kind_Simple_Name => 1990, - Iir_Kind_Selected_Name => 1998, - Iir_Kind_Operator_Symbol => 2003, - Iir_Kind_Reference_Name => 2008, - Iir_Kind_External_Constant_Name => 2017, - Iir_Kind_External_Signal_Name => 2026, - Iir_Kind_External_Variable_Name => 2036, - Iir_Kind_Selected_By_All_Name => 2042, - Iir_Kind_Parenthesis_Name => 2047, - Iir_Kind_Package_Pathname => 2051, - Iir_Kind_Absolute_Pathname => 2052, - Iir_Kind_Relative_Pathname => 2053, - Iir_Kind_Pathname_Element => 2058, - Iir_Kind_Base_Attribute => 2060, - Iir_Kind_Subtype_Attribute => 2065, - Iir_Kind_Element_Attribute => 2070, - Iir_Kind_Across_Attribute => 2075, - Iir_Kind_Through_Attribute => 2080, - Iir_Kind_Nature_Reference_Attribute => 2084, - Iir_Kind_Left_Type_Attribute => 2089, - Iir_Kind_Right_Type_Attribute => 2094, - Iir_Kind_High_Type_Attribute => 2099, - Iir_Kind_Low_Type_Attribute => 2104, - Iir_Kind_Ascending_Type_Attribute => 2109, - Iir_Kind_Image_Attribute => 2115, - Iir_Kind_Value_Attribute => 2121, - Iir_Kind_Pos_Attribute => 2127, - Iir_Kind_Val_Attribute => 2133, - Iir_Kind_Succ_Attribute => 2139, - Iir_Kind_Pred_Attribute => 2145, - Iir_Kind_Leftof_Attribute => 2151, - Iir_Kind_Rightof_Attribute => 2157, - Iir_Kind_Signal_Slew_Attribute => 2165, - Iir_Kind_Quantity_Slew_Attribute => 2173, - Iir_Kind_Ramp_Attribute => 2181, - Iir_Kind_Zoh_Attribute => 2189, - Iir_Kind_Ltf_Attribute => 2197, - Iir_Kind_Ztf_Attribute => 2207, - Iir_Kind_Dot_Attribute => 2214, - Iir_Kind_Integ_Attribute => 2221, - Iir_Kind_Above_Attribute => 2229, - Iir_Kind_Quantity_Delayed_Attribute => 2237, - Iir_Kind_Delayed_Attribute => 2246, - Iir_Kind_Stable_Attribute => 2255, - Iir_Kind_Quiet_Attribute => 2264, - Iir_Kind_Transaction_Attribute => 2273, - Iir_Kind_Event_Attribute => 2277, - Iir_Kind_Active_Attribute => 2281, - Iir_Kind_Last_Event_Attribute => 2285, - Iir_Kind_Last_Active_Attribute => 2289, - Iir_Kind_Last_Value_Attribute => 2293, - Iir_Kind_Driving_Attribute => 2297, - Iir_Kind_Driving_Value_Attribute => 2301, - Iir_Kind_Behavior_Attribute => 2301, - Iir_Kind_Structure_Attribute => 2301, - Iir_Kind_Simple_Name_Attribute => 2308, - Iir_Kind_Instance_Name_Attribute => 2313, - Iir_Kind_Path_Name_Attribute => 2318, - Iir_Kind_Left_Array_Attribute => 2325, - Iir_Kind_Right_Array_Attribute => 2332, - Iir_Kind_High_Array_Attribute => 2339, - Iir_Kind_Low_Array_Attribute => 2346, - Iir_Kind_Length_Array_Attribute => 2353, - Iir_Kind_Ascending_Array_Attribute => 2360, - Iir_Kind_Range_Array_Attribute => 2367, - Iir_Kind_Reverse_Range_Array_Attribute => 2374, - Iir_Kind_Attribute_Name => 2383 + Iir_Kind_Function_Declaration => 828, + Iir_Kind_Procedure_Declaration => 853, + Iir_Kind_Function_Body => 863, + Iir_Kind_Procedure_Body => 874, + Iir_Kind_Function_Instantiation_Declaration => 885, + Iir_Kind_Procedure_Instantiation_Declaration => 895, + Iir_Kind_Terminal_Declaration => 904, + Iir_Kind_Object_Alias_Declaration => 916, + Iir_Kind_Free_Quantity_Declaration => 928, + Iir_Kind_Spectrum_Quantity_Declaration => 941, + Iir_Kind_Noise_Quantity_Declaration => 953, + Iir_Kind_Across_Quantity_Declaration => 969, + Iir_Kind_Through_Quantity_Declaration => 985, + Iir_Kind_File_Declaration => 1000, + Iir_Kind_Guard_Signal_Declaration => 1014, + Iir_Kind_Signal_Declaration => 1031, + Iir_Kind_Variable_Declaration => 1044, + Iir_Kind_Constant_Declaration => 1058, + Iir_Kind_Iterator_Declaration => 1070, + Iir_Kind_Interface_Constant_Declaration => 1087, + Iir_Kind_Interface_Variable_Declaration => 1103, + Iir_Kind_Interface_Signal_Declaration => 1124, + Iir_Kind_Interface_File_Declaration => 1140, + Iir_Kind_Interface_Quantity_Declaration => 1156, + Iir_Kind_Interface_Terminal_Declaration => 1168, + Iir_Kind_Interface_Type_Declaration => 1179, + Iir_Kind_Interface_Package_Declaration => 1192, + Iir_Kind_Interface_Function_Declaration => 1210, + Iir_Kind_Interface_Procedure_Declaration => 1224, + Iir_Kind_Signal_Attribute_Declaration => 1227, + Iir_Kind_Identity_Operator => 1231, + Iir_Kind_Negation_Operator => 1235, + Iir_Kind_Absolute_Operator => 1239, + Iir_Kind_Not_Operator => 1243, + Iir_Kind_Implicit_Condition_Operator => 1247, + Iir_Kind_Condition_Operator => 1251, + Iir_Kind_Reduction_And_Operator => 1255, + Iir_Kind_Reduction_Or_Operator => 1259, + Iir_Kind_Reduction_Nand_Operator => 1263, + Iir_Kind_Reduction_Nor_Operator => 1267, + Iir_Kind_Reduction_Xor_Operator => 1271, + Iir_Kind_Reduction_Xnor_Operator => 1275, + Iir_Kind_And_Operator => 1280, + Iir_Kind_Or_Operator => 1285, + Iir_Kind_Nand_Operator => 1290, + Iir_Kind_Nor_Operator => 1295, + Iir_Kind_Xor_Operator => 1300, + Iir_Kind_Xnor_Operator => 1305, + Iir_Kind_Equality_Operator => 1310, + Iir_Kind_Inequality_Operator => 1315, + Iir_Kind_Less_Than_Operator => 1320, + Iir_Kind_Less_Than_Or_Equal_Operator => 1325, + Iir_Kind_Greater_Than_Operator => 1330, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1335, + Iir_Kind_Match_Equality_Operator => 1340, + Iir_Kind_Match_Inequality_Operator => 1345, + Iir_Kind_Match_Less_Than_Operator => 1350, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1355, + Iir_Kind_Match_Greater_Than_Operator => 1360, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1365, + Iir_Kind_Sll_Operator => 1370, + Iir_Kind_Sla_Operator => 1375, + Iir_Kind_Srl_Operator => 1380, + Iir_Kind_Sra_Operator => 1385, + Iir_Kind_Rol_Operator => 1390, + Iir_Kind_Ror_Operator => 1395, + Iir_Kind_Addition_Operator => 1400, + Iir_Kind_Substraction_Operator => 1405, + Iir_Kind_Concatenation_Operator => 1410, + Iir_Kind_Multiplication_Operator => 1415, + Iir_Kind_Division_Operator => 1420, + Iir_Kind_Modulus_Operator => 1425, + Iir_Kind_Remainder_Operator => 1430, + Iir_Kind_Exponentiation_Operator => 1435, + Iir_Kind_Function_Call => 1443, + Iir_Kind_Aggregate => 1450, + Iir_Kind_Parenthesis_Expression => 1453, + Iir_Kind_Qualified_Expression => 1457, + Iir_Kind_Type_Conversion => 1462, + Iir_Kind_Allocator_By_Expression => 1467, + Iir_Kind_Allocator_By_Subtype => 1473, + Iir_Kind_Selected_Element => 1481, + Iir_Kind_Dereference => 1486, + Iir_Kind_Implicit_Dereference => 1491, + Iir_Kind_Slice_Name => 1498, + Iir_Kind_Indexed_Name => 1504, + Iir_Kind_Psl_Prev => 1510, + Iir_Kind_Psl_Stable => 1515, + Iir_Kind_Psl_Rose => 1520, + Iir_Kind_Psl_Fell => 1525, + Iir_Kind_Psl_Onehot => 1528, + Iir_Kind_Psl_Onehot0 => 1531, + Iir_Kind_Psl_Expression => 1533, + Iir_Kind_Sensitized_Process_Statement => 1554, + Iir_Kind_Process_Statement => 1574, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1587, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1600, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1614, + Iir_Kind_Concurrent_Assertion_Statement => 1622, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1629, + Iir_Kind_Concurrent_Break_Statement => 1637, + Iir_Kind_Psl_Assert_Directive => 1651, + Iir_Kind_Psl_Assume_Directive => 1663, + Iir_Kind_Psl_Cover_Directive => 1675, + Iir_Kind_Psl_Restrict_Directive => 1686, + Iir_Kind_Block_Statement => 1700, + Iir_Kind_If_Generate_Statement => 1711, + Iir_Kind_Case_Generate_Statement => 1720, + Iir_Kind_For_Generate_Statement => 1729, + Iir_Kind_Component_Instantiation_Statement => 1740, + Iir_Kind_Psl_Default_Clock => 1743, + Iir_Kind_Generate_Statement_Body => 1754, + Iir_Kind_If_Generate_Else_Clause => 1760, + Iir_Kind_Simple_Simultaneous_Statement => 1767, + Iir_Kind_Simultaneous_Null_Statement => 1771, + Iir_Kind_Simultaneous_Procedural_Statement => 1782, + Iir_Kind_Simultaneous_Case_Statement => 1791, + Iir_Kind_Simultaneous_If_Statement => 1800, + Iir_Kind_Simultaneous_Elsif => 1806, + Iir_Kind_Simple_Signal_Assignment_Statement => 1817, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1828, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1840, + Iir_Kind_Signal_Force_Assignment_Statement => 1850, + Iir_Kind_Signal_Release_Assignment_Statement => 1859, + Iir_Kind_Null_Statement => 1863, + Iir_Kind_Assertion_Statement => 1870, + Iir_Kind_Report_Statement => 1876, + Iir_Kind_Wait_Statement => 1884, + Iir_Kind_Variable_Assignment_Statement => 1891, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1898, + Iir_Kind_Return_Statement => 1904, + Iir_Kind_For_Loop_Statement => 1915, + Iir_Kind_While_Loop_Statement => 1926, + Iir_Kind_Next_Statement => 1933, + Iir_Kind_Exit_Statement => 1940, + Iir_Kind_Case_Statement => 1949, + Iir_Kind_Procedure_Call_Statement => 1955, + Iir_Kind_Break_Statement => 1962, + Iir_Kind_If_Statement => 1972, + Iir_Kind_Elsif => 1978, + Iir_Kind_Character_Literal => 1985, + Iir_Kind_Simple_Name => 1992, + Iir_Kind_Selected_Name => 2000, + Iir_Kind_Operator_Symbol => 2005, + Iir_Kind_Reference_Name => 2010, + Iir_Kind_External_Constant_Name => 2019, + Iir_Kind_External_Signal_Name => 2028, + Iir_Kind_External_Variable_Name => 2038, + Iir_Kind_Selected_By_All_Name => 2044, + Iir_Kind_Parenthesis_Name => 2049, + Iir_Kind_Package_Pathname => 2053, + Iir_Kind_Absolute_Pathname => 2054, + Iir_Kind_Relative_Pathname => 2055, + Iir_Kind_Pathname_Element => 2060, + Iir_Kind_Base_Attribute => 2062, + Iir_Kind_Subtype_Attribute => 2067, + Iir_Kind_Element_Attribute => 2072, + Iir_Kind_Across_Attribute => 2077, + Iir_Kind_Through_Attribute => 2082, + Iir_Kind_Nature_Reference_Attribute => 2086, + Iir_Kind_Left_Type_Attribute => 2091, + Iir_Kind_Right_Type_Attribute => 2096, + Iir_Kind_High_Type_Attribute => 2101, + Iir_Kind_Low_Type_Attribute => 2106, + Iir_Kind_Ascending_Type_Attribute => 2111, + Iir_Kind_Image_Attribute => 2117, + Iir_Kind_Value_Attribute => 2123, + Iir_Kind_Pos_Attribute => 2129, + Iir_Kind_Val_Attribute => 2135, + Iir_Kind_Succ_Attribute => 2141, + Iir_Kind_Pred_Attribute => 2147, + Iir_Kind_Leftof_Attribute => 2153, + Iir_Kind_Rightof_Attribute => 2159, + Iir_Kind_Signal_Slew_Attribute => 2167, + Iir_Kind_Quantity_Slew_Attribute => 2175, + Iir_Kind_Ramp_Attribute => 2183, + Iir_Kind_Zoh_Attribute => 2191, + Iir_Kind_Ltf_Attribute => 2199, + Iir_Kind_Ztf_Attribute => 2209, + Iir_Kind_Dot_Attribute => 2216, + Iir_Kind_Integ_Attribute => 2223, + Iir_Kind_Above_Attribute => 2231, + Iir_Kind_Quantity_Delayed_Attribute => 2239, + Iir_Kind_Delayed_Attribute => 2248, + Iir_Kind_Stable_Attribute => 2257, + Iir_Kind_Quiet_Attribute => 2266, + Iir_Kind_Transaction_Attribute => 2275, + Iir_Kind_Event_Attribute => 2279, + Iir_Kind_Active_Attribute => 2283, + Iir_Kind_Last_Event_Attribute => 2287, + Iir_Kind_Last_Active_Attribute => 2291, + Iir_Kind_Last_Value_Attribute => 2295, + Iir_Kind_Driving_Attribute => 2299, + Iir_Kind_Driving_Value_Attribute => 2303, + Iir_Kind_Behavior_Attribute => 2303, + Iir_Kind_Structure_Attribute => 2303, + Iir_Kind_Simple_Name_Attribute => 2310, + Iir_Kind_Instance_Name_Attribute => 2315, + Iir_Kind_Path_Name_Attribute => 2320, + Iir_Kind_Left_Array_Attribute => 2327, + Iir_Kind_Right_Array_Attribute => 2334, + Iir_Kind_High_Array_Attribute => 2341, + Iir_Kind_Low_Array_Attribute => 2348, + Iir_Kind_Length_Array_Attribute => 2355, + Iir_Kind_Ascending_Array_Attribute => 2362, + Iir_Kind_Range_Array_Attribute => 2369, + Iir_Kind_Reverse_Range_Array_Attribute => 2376, + Iir_Kind_Attribute_Name => 2385 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -6210,6 +6217,8 @@ package body Vhdl.Nodes_Meta is return Get_Unit_Chain (N); when Field_Primary_Unit => return Get_Primary_Unit (N); + when Field_Return_Identifier => + return Get_Return_Identifier (N); when Field_Range_Constraint => return Get_Range_Constraint (N); when Field_Left_Limit => @@ -6666,6 +6675,8 @@ package body Vhdl.Nodes_Meta is Set_Unit_Chain (N, V); when Field_Primary_Unit => Set_Primary_Unit (N, V); + when Field_Return_Identifier => + Set_Return_Identifier (N, V); when Field_Range_Constraint => Set_Range_Constraint (N, V); when Field_Left_Limit => @@ -9564,6 +9575,17 @@ package body Vhdl.Nodes_Meta is end case; end Has_Label; + function Has_Return_Identifier (K : Iir_Kind) return Boolean is + begin + case K is + when Iir_Kind_Function_Declaration + | Iir_Kind_Procedure_Declaration => + return True; + when others => + return False; + end case; + end Has_Return_Identifier; + function Has_Visible_Flag (K : Iir_Kind) return Boolean is begin case K is diff --git a/src/vhdl/vhdl-nodes_meta.ads b/src/vhdl/vhdl-nodes_meta.ads index 44ae8b048..15e9c1b3d 100644 --- a/src/vhdl/vhdl-nodes_meta.ads +++ b/src/vhdl/vhdl-nodes_meta.ads @@ -205,6 +205,7 @@ package Vhdl.Nodes_Meta is Field_Primary_Unit, Field_Identifier, Field_Label, + Field_Return_Identifier, Field_Visible_Flag, Field_Range_Constraint, Field_Direction, @@ -791,6 +792,7 @@ package Vhdl.Nodes_Meta is function Has_Primary_Unit (K : Iir_Kind) return Boolean; function Has_Identifier (K : Iir_Kind) return Boolean; function Has_Label (K : Iir_Kind) return Boolean; + function Has_Return_Identifier (K : Iir_Kind) return Boolean; function Has_Visible_Flag (K : Iir_Kind) return Boolean; function Has_Range_Constraint (K : Iir_Kind) return Boolean; function Has_Direction (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index e84f7d726..6e574b0a5 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -2100,6 +2100,8 @@ package body Vhdl.Parse is is Old : Iir; pragma Unreferenced (Old); + Tm : Iir; + Ret : Iir; Inters : Iir; begin if Current_Token = Tok_Parameter then @@ -2141,8 +2143,27 @@ package body Vhdl.Parse is -- Skip 'return' Scan; - Set_Return_Type_Mark - (Subprg, Parse_Type_Mark (Check_Paren => True)); + Tm := Parse_Type_Mark (Check_Paren => True); + + if Current_Token = Tok_Of then + if Vhdl_Std < Vhdl_19 then + Error_Msg_Parse + ("return identifier not allowed before vhdl 2019"); + end if; + pragma Assert (Get_Kind (Tm) = Iir_Kind_Simple_Name); + Ret := Create_Iir (Iir_Kind_Subtype_Declaration); + Location_Copy (Ret, Tm); + Set_Identifier (Ret, Get_Identifier (Tm)); + Set_Return_Identifier (Subprg, Ret); + Free_Iir (Tm); + + -- Skip 'of' + Scan; + + Tm := Parse_Type_Mark (Check_Paren => True); + end if; + + Set_Return_Type_Mark (Subprg, Tm); end if; else if Is_Func and Required then @@ -8298,6 +8319,12 @@ package body Vhdl.Parse is -- | [ PURE | IMPURE ] FUNCTION designator [ ( formal_parameter_list ) ] -- RETURN type_mark -- + -- [ LRM19 4.2 Subprogram declarations ] + -- function_specification ::= + -- [ PURE | IMPURE ] FUNCTION designator + -- subprogram_header [ [ PARAMETER ] ( formal_parameter_list) ] + -- RETURN [ return_identifier OF ] type_mark + -- -- [ LRM93 2.2 ] -- subprogram_body ::= -- subprogram_specification IS |