aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-09-20 06:41:12 +0200
committerTristan Gingold <tgingold@free.fr>2017-09-25 18:32:44 +0200
commitbddca1f6254ca6e4e9b9f4bda0ff77c7bba7d2db (patch)
tree32e1a61399e81e999b5f1b08b4357a0c5a2f4883
parent9b4b6d4bdf555ec3fcd1facfa788f2e6284451f8 (diff)
downloadghdl-bddca1f6254ca6e4e9b9f4bda0ff77c7bba7d2db.tar.gz
ghdl-bddca1f6254ca6e4e9b9f4bda0ff77c7bba7d2db.tar.bz2
ghdl-bddca1f6254ca6e4e9b9f4bda0ff77c7bba7d2db.zip
sem_assocs: rewrite (pass v87)
-rw-r--r--src/vhdl/iirs.adb16
-rw-r--r--src/vhdl/iirs.ads17
-rw-r--r--src/vhdl/nodes_meta.adb528
-rw-r--r--src/vhdl/nodes_meta.ads2
-rw-r--r--src/vhdl/parse.adb1
-rw-r--r--src/vhdl/sem_assocs.adb653
-rw-r--r--src/vhdl/sem_names.adb42
-rw-r--r--src/vhdl/sem_names.ads2
8 files changed, 592 insertions, 669 deletions
diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb
index 8c3b74987..bcbbc842e 100644
--- a/src/vhdl/iirs.adb
+++ b/src/vhdl/iirs.adb
@@ -4625,6 +4625,22 @@ package body Iirs is
Set_Field5 (Path, Expr);
end Set_Pathname_Expression;
+ function Get_In_Formal_Flag (Name : Iir) return Boolean is
+ begin
+ pragma Assert (Name /= Null_Iir);
+ pragma Assert (Has_In_Formal_Flag (Get_Kind (Name)),
+ "no field In_Formal_Flag");
+ return Get_Flag4 (Name);
+ end Get_In_Formal_Flag;
+
+ procedure Set_In_Formal_Flag (Name : Iir; Flag : Boolean) is
+ begin
+ pragma Assert (Name /= Null_Iir);
+ pragma Assert (Has_In_Formal_Flag (Get_Kind (Name)),
+ "no field In_Formal_Flag");
+ Set_Flag4 (Name, Flag);
+ end Set_In_Formal_Flag;
+
function Get_Slice_Subtype (Slice : Iir) return Iir is
begin
pragma Assert (Slice /= Null_Iir);
diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads
index 53d28cecf..cebb3b013 100644
--- a/src/vhdl/iirs.ads
+++ b/src/vhdl/iirs.ads
@@ -471,6 +471,8 @@ package Iirs is
-- Only for Iir_Kind_Association_Element_Open:
-- Get/Set_Artificial_Flag (Flag3)
--
+ -- Get/Set_In_Formal_Flag (Flag4)
+ --
-- Only for Iir_Kind_Association_Element_By_Individual:
-- Must be Locally unless there is an error on one choice.
-- Get/Set_Choice_Staticness (State1)
@@ -5050,6 +5052,10 @@ package Iirs is
--Iir_Kind_Interface_Signal_Declaration
Iir_Kind_Interface_File_Declaration;
+ subtype Iir_Kinds_Interface_Subprogram_Declaration is Iir_Kind range
+ Iir_Kind_Interface_Function_Declaration ..
+ Iir_Kind_Interface_Procedure_Declaration;
+
subtype Iir_Kinds_Interface_Declaration is Iir_Kind range
Iir_Kind_Interface_Constant_Declaration ..
--Iir_Kind_Interface_Variable_Declaration
@@ -5073,10 +5079,6 @@ package Iirs is
--Iir_Kind_Interface_Signal_Declaration
Iir_Kind_Interface_File_Declaration;
- subtype Iir_Kinds_Interface_Subprogram_Declaration is Iir_Kind range
- Iir_Kind_Interface_Function_Declaration ..
- Iir_Kind_Interface_Procedure_Declaration;
-
subtype Iir_Kinds_Branch_Quantity_Declaration is Iir_Kind range
Iir_Kind_Across_Quantity_Declaration ..
Iir_Kind_Through_Quantity_Declaration;
@@ -7005,6 +7007,13 @@ package Iirs is
function Get_Pathname_Expression (Path : Iir) return Iir;
procedure Set_Pathname_Expression (Path : Iir; Expr : Iir);
+ -- True if the name appears in a formal_part. In that case, some
+ -- checks must be disabled (eg: the expression of a type conversion can
+ -- be a write-only interface).
+ -- Field: Flag4
+ function Get_In_Formal_Flag (Name : Iir) return Boolean;
+ procedure Set_In_Formal_Flag (Name : Iir; Flag : Boolean);
+
-- The subtype of a slice. Contrary to the Type field, this is not a
-- reference.
-- Field: Field3
diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb
index d5aeba314..38fcca01c 100644
--- a/src/vhdl/nodes_meta.adb
+++ b/src/vhdl/nodes_meta.adb
@@ -269,6 +269,7 @@ package body Nodes_Meta is
Field_External_Pathname => Type_Iir,
Field_Pathname_Suffix => Type_Iir,
Field_Pathname_Expression => Type_Iir,
+ Field_In_Formal_Flag => Type_Boolean,
Field_Slice_Subtype => Type_Iir,
Field_Suffix => Type_Iir,
Field_Index_Subtype => Type_Iir,
@@ -851,6 +852,8 @@ package body Nodes_Meta is
return "pathname_suffix";
when Field_Pathname_Expression =>
return "pathname_expression";
+ when Field_In_Formal_Flag =>
+ return "in_formal_flag";
when Field_Slice_Subtype =>
return "slice_subtype";
when Field_Suffix =>
@@ -2043,6 +2046,8 @@ package body Nodes_Meta is
return Attr_None;
when Field_Pathname_Expression =>
return Attr_None;
+ when Field_In_Formal_Flag =>
+ return Attr_None;
when Field_Slice_Subtype =>
return Attr_None;
when Field_Suffix =>
@@ -2314,6 +2319,7 @@ package body Nodes_Meta is
-- Iir_Kind_Association_Element_By_Expression
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
+ Field_In_Formal_Flag,
Field_Formal,
Field_Chain,
Field_Actual,
@@ -2322,6 +2328,7 @@ package body Nodes_Meta is
-- Iir_Kind_Association_Element_By_Individual
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
+ Field_In_Formal_Flag,
Field_Choice_Staticness,
Field_Formal,
Field_Chain,
@@ -2332,17 +2339,20 @@ package body Nodes_Meta is
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
Field_Artificial_Flag,
+ Field_In_Formal_Flag,
Field_Formal,
Field_Chain,
-- Iir_Kind_Association_Element_Package
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
+ Field_In_Formal_Flag,
Field_Formal,
Field_Chain,
Field_Actual,
-- Iir_Kind_Association_Element_Type
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
+ Field_In_Formal_Flag,
Field_Formal,
Field_Chain,
Field_Actual,
@@ -2351,6 +2361,7 @@ package body Nodes_Meta is
-- Iir_Kind_Association_Element_Subprogram
Field_Whole_Association_Flag,
Field_Collapse_Signal_Flag,
+ Field_In_Formal_Flag,
Field_Formal,
Field_Chain,
Field_Actual,
@@ -4380,255 +4391,255 @@ package body Nodes_Meta is
Iir_Kind_Waveform_Element => 91,
Iir_Kind_Conditional_Waveform => 95,
Iir_Kind_Conditional_Expression => 99,
- Iir_Kind_Association_Element_By_Expression => 106,
- Iir_Kind_Association_Element_By_Individual => 114,
- Iir_Kind_Association_Element_Open => 119,
- Iir_Kind_Association_Element_Package => 124,
- Iir_Kind_Association_Element_Type => 131,
- Iir_Kind_Association_Element_Subprogram => 136,
- Iir_Kind_Choice_By_Range => 143,
- Iir_Kind_Choice_By_Expression => 150,
- Iir_Kind_Choice_By_Others => 155,
- Iir_Kind_Choice_By_None => 160,
- Iir_Kind_Choice_By_Name => 166,
- Iir_Kind_Entity_Aspect_Entity => 168,
- Iir_Kind_Entity_Aspect_Configuration => 169,
- Iir_Kind_Entity_Aspect_Open => 169,
- Iir_Kind_Block_Configuration => 175,
- Iir_Kind_Block_Header => 179,
- Iir_Kind_Component_Configuration => 186,
- Iir_Kind_Binding_Indication => 190,
- Iir_Kind_Entity_Class => 192,
- Iir_Kind_Attribute_Value => 200,
- Iir_Kind_Signature => 203,
- Iir_Kind_Aggregate_Info => 210,
- Iir_Kind_Procedure_Call => 214,
- Iir_Kind_Record_Element_Constraint => 221,
- Iir_Kind_Array_Element_Resolution => 223,
- Iir_Kind_Record_Resolution => 224,
- Iir_Kind_Record_Element_Resolution => 227,
- Iir_Kind_Attribute_Specification => 235,
- Iir_Kind_Disconnection_Specification => 241,
- Iir_Kind_Configuration_Specification => 247,
- Iir_Kind_Access_Type_Definition => 255,
- Iir_Kind_Incomplete_Type_Definition => 263,
- Iir_Kind_Interface_Type_Definition => 270,
- Iir_Kind_File_Type_Definition => 277,
- Iir_Kind_Protected_Type_Declaration => 286,
- Iir_Kind_Record_Type_Definition => 296,
- Iir_Kind_Array_Type_Definition => 308,
- Iir_Kind_Array_Subtype_Definition => 323,
- Iir_Kind_Record_Subtype_Definition => 334,
- Iir_Kind_Access_Subtype_Definition => 342,
- Iir_Kind_Physical_Subtype_Definition => 352,
- Iir_Kind_Floating_Subtype_Definition => 363,
- Iir_Kind_Integer_Subtype_Definition => 373,
- Iir_Kind_Enumeration_Subtype_Definition => 383,
- Iir_Kind_Enumeration_Type_Definition => 393,
- Iir_Kind_Integer_Type_Definition => 401,
- Iir_Kind_Floating_Type_Definition => 409,
- Iir_Kind_Physical_Type_Definition => 420,
- Iir_Kind_Range_Expression => 428,
- Iir_Kind_Protected_Type_Body => 435,
- Iir_Kind_Wildcard_Type_Definition => 440,
- Iir_Kind_Subtype_Definition => 445,
- Iir_Kind_Scalar_Nature_Definition => 449,
- Iir_Kind_Overload_List => 450,
- Iir_Kind_Type_Declaration => 457,
- Iir_Kind_Anonymous_Type_Declaration => 463,
- Iir_Kind_Subtype_Declaration => 470,
- Iir_Kind_Nature_Declaration => 476,
- Iir_Kind_Subnature_Declaration => 482,
- Iir_Kind_Package_Declaration => 496,
- Iir_Kind_Package_Instantiation_Declaration => 509,
- Iir_Kind_Package_Body => 517,
- Iir_Kind_Configuration_Declaration => 526,
- Iir_Kind_Entity_Declaration => 538,
- Iir_Kind_Architecture_Body => 550,
- Iir_Kind_Context_Declaration => 556,
- Iir_Kind_Package_Header => 558,
- Iir_Kind_Unit_Declaration => 566,
- Iir_Kind_Library_Declaration => 573,
- Iir_Kind_Component_Declaration => 583,
- Iir_Kind_Attribute_Declaration => 590,
- Iir_Kind_Group_Template_Declaration => 596,
- Iir_Kind_Group_Declaration => 603,
- Iir_Kind_Element_Declaration => 611,
- Iir_Kind_Non_Object_Alias_Declaration => 619,
- Iir_Kind_Psl_Declaration => 627,
- Iir_Kind_Psl_Endpoint_Declaration => 641,
- Iir_Kind_Terminal_Declaration => 647,
- Iir_Kind_Free_Quantity_Declaration => 656,
- Iir_Kind_Across_Quantity_Declaration => 668,
- Iir_Kind_Through_Quantity_Declaration => 680,
- Iir_Kind_Enumeration_Literal => 691,
- Iir_Kind_Function_Declaration => 716,
- Iir_Kind_Procedure_Declaration => 740,
- Iir_Kind_Function_Body => 750,
- Iir_Kind_Procedure_Body => 761,
- Iir_Kind_Object_Alias_Declaration => 772,
- Iir_Kind_File_Declaration => 786,
- Iir_Kind_Guard_Signal_Declaration => 799,
- Iir_Kind_Signal_Declaration => 816,
- Iir_Kind_Variable_Declaration => 829,
- Iir_Kind_Constant_Declaration => 843,
- Iir_Kind_Iterator_Declaration => 854,
- Iir_Kind_Interface_Constant_Declaration => 870,
- Iir_Kind_Interface_Variable_Declaration => 886,
- Iir_Kind_Interface_Signal_Declaration => 907,
- Iir_Kind_Interface_File_Declaration => 923,
- Iir_Kind_Interface_Type_Declaration => 933,
- Iir_Kind_Interface_Package_Declaration => 944,
- Iir_Kind_Interface_Function_Declaration => 961,
- Iir_Kind_Interface_Procedure_Declaration => 974,
- Iir_Kind_Signal_Attribute_Declaration => 977,
- Iir_Kind_Identity_Operator => 981,
- Iir_Kind_Negation_Operator => 985,
- Iir_Kind_Absolute_Operator => 989,
- Iir_Kind_Not_Operator => 993,
- Iir_Kind_Condition_Operator => 997,
- Iir_Kind_Reduction_And_Operator => 1001,
- Iir_Kind_Reduction_Or_Operator => 1005,
- Iir_Kind_Reduction_Nand_Operator => 1009,
- Iir_Kind_Reduction_Nor_Operator => 1013,
- Iir_Kind_Reduction_Xor_Operator => 1017,
- Iir_Kind_Reduction_Xnor_Operator => 1021,
- Iir_Kind_And_Operator => 1026,
- Iir_Kind_Or_Operator => 1031,
- Iir_Kind_Nand_Operator => 1036,
- Iir_Kind_Nor_Operator => 1041,
- Iir_Kind_Xor_Operator => 1046,
- Iir_Kind_Xnor_Operator => 1051,
- Iir_Kind_Equality_Operator => 1056,
- Iir_Kind_Inequality_Operator => 1061,
- Iir_Kind_Less_Than_Operator => 1066,
- Iir_Kind_Less_Than_Or_Equal_Operator => 1071,
- Iir_Kind_Greater_Than_Operator => 1076,
- Iir_Kind_Greater_Than_Or_Equal_Operator => 1081,
- Iir_Kind_Match_Equality_Operator => 1086,
- Iir_Kind_Match_Inequality_Operator => 1091,
- Iir_Kind_Match_Less_Than_Operator => 1096,
- Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1101,
- Iir_Kind_Match_Greater_Than_Operator => 1106,
- Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1111,
- Iir_Kind_Sll_Operator => 1116,
- Iir_Kind_Sla_Operator => 1121,
- Iir_Kind_Srl_Operator => 1126,
- Iir_Kind_Sra_Operator => 1131,
- Iir_Kind_Rol_Operator => 1136,
- Iir_Kind_Ror_Operator => 1141,
- Iir_Kind_Addition_Operator => 1146,
- Iir_Kind_Substraction_Operator => 1151,
- Iir_Kind_Concatenation_Operator => 1156,
- Iir_Kind_Multiplication_Operator => 1161,
- Iir_Kind_Division_Operator => 1166,
- Iir_Kind_Modulus_Operator => 1171,
- Iir_Kind_Remainder_Operator => 1176,
- Iir_Kind_Exponentiation_Operator => 1181,
- Iir_Kind_Function_Call => 1189,
- Iir_Kind_Aggregate => 1196,
- Iir_Kind_Parenthesis_Expression => 1199,
- Iir_Kind_Qualified_Expression => 1203,
- Iir_Kind_Type_Conversion => 1208,
- Iir_Kind_Allocator_By_Expression => 1212,
- Iir_Kind_Allocator_By_Subtype => 1217,
- Iir_Kind_Selected_Element => 1223,
- Iir_Kind_Dereference => 1228,
- Iir_Kind_Implicit_Dereference => 1233,
- Iir_Kind_Slice_Name => 1240,
- Iir_Kind_Indexed_Name => 1246,
- Iir_Kind_Psl_Expression => 1248,
- Iir_Kind_Sensitized_Process_Statement => 1269,
- Iir_Kind_Process_Statement => 1289,
- Iir_Kind_Concurrent_Simple_Signal_Assignment => 1301,
- Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1313,
- Iir_Kind_Concurrent_Selected_Signal_Assignment => 1326,
- Iir_Kind_Concurrent_Assertion_Statement => 1334,
- Iir_Kind_Concurrent_Procedure_Call_Statement => 1341,
- Iir_Kind_Psl_Assert_Statement => 1354,
- Iir_Kind_Psl_Cover_Statement => 1367,
- Iir_Kind_Block_Statement => 1380,
- Iir_Kind_If_Generate_Statement => 1391,
- Iir_Kind_Case_Generate_Statement => 1400,
- Iir_Kind_For_Generate_Statement => 1409,
- Iir_Kind_Component_Instantiation_Statement => 1419,
- Iir_Kind_Psl_Default_Clock => 1423,
- Iir_Kind_Simple_Simultaneous_Statement => 1430,
- Iir_Kind_Generate_Statement_Body => 1441,
- Iir_Kind_If_Generate_Else_Clause => 1447,
- Iir_Kind_Simple_Signal_Assignment_Statement => 1457,
- Iir_Kind_Conditional_Signal_Assignment_Statement => 1467,
- Iir_Kind_Selected_Waveform_Assignment_Statement => 1478,
- Iir_Kind_Null_Statement => 1482,
- Iir_Kind_Assertion_Statement => 1489,
- Iir_Kind_Report_Statement => 1495,
- Iir_Kind_Wait_Statement => 1503,
- Iir_Kind_Variable_Assignment_Statement => 1510,
- Iir_Kind_Conditional_Variable_Assignment_Statement => 1517,
- Iir_Kind_Return_Statement => 1523,
- Iir_Kind_For_Loop_Statement => 1532,
- Iir_Kind_While_Loop_Statement => 1541,
- Iir_Kind_Next_Statement => 1548,
- Iir_Kind_Exit_Statement => 1555,
- Iir_Kind_Case_Statement => 1563,
- Iir_Kind_Procedure_Call_Statement => 1569,
- Iir_Kind_If_Statement => 1579,
- Iir_Kind_Elsif => 1585,
- Iir_Kind_Character_Literal => 1593,
- Iir_Kind_Simple_Name => 1601,
- Iir_Kind_Selected_Name => 1610,
- Iir_Kind_Operator_Symbol => 1616,
- Iir_Kind_Reference_Name => 1619,
- Iir_Kind_Selected_By_All_Name => 1625,
- Iir_Kind_Parenthesis_Name => 1630,
- Iir_Kind_External_Constant_Name => 1638,
- Iir_Kind_External_Signal_Name => 1646,
- Iir_Kind_External_Variable_Name => 1654,
- Iir_Kind_Package_Pathname => 1658,
- Iir_Kind_Absolute_Pathname => 1659,
- Iir_Kind_Relative_Pathname => 1660,
- Iir_Kind_Pathname_Element => 1665,
- Iir_Kind_Base_Attribute => 1667,
- Iir_Kind_Subtype_Attribute => 1672,
- Iir_Kind_Element_Attribute => 1677,
- Iir_Kind_Left_Type_Attribute => 1682,
- Iir_Kind_Right_Type_Attribute => 1687,
- Iir_Kind_High_Type_Attribute => 1692,
- Iir_Kind_Low_Type_Attribute => 1697,
- Iir_Kind_Ascending_Type_Attribute => 1702,
- Iir_Kind_Image_Attribute => 1708,
- Iir_Kind_Value_Attribute => 1714,
- Iir_Kind_Pos_Attribute => 1720,
- Iir_Kind_Val_Attribute => 1726,
- Iir_Kind_Succ_Attribute => 1732,
- Iir_Kind_Pred_Attribute => 1738,
- Iir_Kind_Leftof_Attribute => 1744,
- Iir_Kind_Rightof_Attribute => 1750,
- Iir_Kind_Delayed_Attribute => 1759,
- Iir_Kind_Stable_Attribute => 1768,
- Iir_Kind_Quiet_Attribute => 1777,
- Iir_Kind_Transaction_Attribute => 1786,
- Iir_Kind_Event_Attribute => 1790,
- Iir_Kind_Active_Attribute => 1794,
- Iir_Kind_Last_Event_Attribute => 1798,
- Iir_Kind_Last_Active_Attribute => 1802,
- Iir_Kind_Last_Value_Attribute => 1806,
- Iir_Kind_Driving_Attribute => 1810,
- Iir_Kind_Driving_Value_Attribute => 1814,
- Iir_Kind_Behavior_Attribute => 1814,
- Iir_Kind_Structure_Attribute => 1814,
- Iir_Kind_Simple_Name_Attribute => 1821,
- Iir_Kind_Instance_Name_Attribute => 1826,
- Iir_Kind_Path_Name_Attribute => 1831,
- Iir_Kind_Left_Array_Attribute => 1838,
- Iir_Kind_Right_Array_Attribute => 1845,
- Iir_Kind_High_Array_Attribute => 1852,
- Iir_Kind_Low_Array_Attribute => 1859,
- Iir_Kind_Length_Array_Attribute => 1866,
- Iir_Kind_Ascending_Array_Attribute => 1873,
- Iir_Kind_Range_Array_Attribute => 1880,
- Iir_Kind_Reverse_Range_Array_Attribute => 1887,
- Iir_Kind_Attribute_Name => 1896
+ Iir_Kind_Association_Element_By_Expression => 107,
+ Iir_Kind_Association_Element_By_Individual => 116,
+ Iir_Kind_Association_Element_Open => 122,
+ Iir_Kind_Association_Element_Package => 128,
+ Iir_Kind_Association_Element_Type => 136,
+ Iir_Kind_Association_Element_Subprogram => 142,
+ Iir_Kind_Choice_By_Range => 149,
+ Iir_Kind_Choice_By_Expression => 156,
+ Iir_Kind_Choice_By_Others => 161,
+ Iir_Kind_Choice_By_None => 166,
+ Iir_Kind_Choice_By_Name => 172,
+ Iir_Kind_Entity_Aspect_Entity => 174,
+ Iir_Kind_Entity_Aspect_Configuration => 175,
+ Iir_Kind_Entity_Aspect_Open => 175,
+ Iir_Kind_Block_Configuration => 181,
+ Iir_Kind_Block_Header => 185,
+ Iir_Kind_Component_Configuration => 192,
+ Iir_Kind_Binding_Indication => 196,
+ Iir_Kind_Entity_Class => 198,
+ Iir_Kind_Attribute_Value => 206,
+ Iir_Kind_Signature => 209,
+ Iir_Kind_Aggregate_Info => 216,
+ Iir_Kind_Procedure_Call => 220,
+ Iir_Kind_Record_Element_Constraint => 227,
+ Iir_Kind_Array_Element_Resolution => 229,
+ Iir_Kind_Record_Resolution => 230,
+ Iir_Kind_Record_Element_Resolution => 233,
+ Iir_Kind_Attribute_Specification => 241,
+ Iir_Kind_Disconnection_Specification => 247,
+ Iir_Kind_Configuration_Specification => 253,
+ Iir_Kind_Access_Type_Definition => 261,
+ Iir_Kind_Incomplete_Type_Definition => 269,
+ Iir_Kind_Interface_Type_Definition => 276,
+ Iir_Kind_File_Type_Definition => 283,
+ Iir_Kind_Protected_Type_Declaration => 292,
+ Iir_Kind_Record_Type_Definition => 302,
+ Iir_Kind_Array_Type_Definition => 314,
+ Iir_Kind_Array_Subtype_Definition => 329,
+ Iir_Kind_Record_Subtype_Definition => 340,
+ Iir_Kind_Access_Subtype_Definition => 348,
+ Iir_Kind_Physical_Subtype_Definition => 358,
+ Iir_Kind_Floating_Subtype_Definition => 369,
+ Iir_Kind_Integer_Subtype_Definition => 379,
+ Iir_Kind_Enumeration_Subtype_Definition => 389,
+ Iir_Kind_Enumeration_Type_Definition => 399,
+ Iir_Kind_Integer_Type_Definition => 407,
+ Iir_Kind_Floating_Type_Definition => 415,
+ Iir_Kind_Physical_Type_Definition => 426,
+ Iir_Kind_Range_Expression => 434,
+ Iir_Kind_Protected_Type_Body => 441,
+ Iir_Kind_Wildcard_Type_Definition => 446,
+ Iir_Kind_Subtype_Definition => 451,
+ Iir_Kind_Scalar_Nature_Definition => 455,
+ Iir_Kind_Overload_List => 456,
+ Iir_Kind_Type_Declaration => 463,
+ Iir_Kind_Anonymous_Type_Declaration => 469,
+ Iir_Kind_Subtype_Declaration => 476,
+ Iir_Kind_Nature_Declaration => 482,
+ Iir_Kind_Subnature_Declaration => 488,
+ Iir_Kind_Package_Declaration => 502,
+ Iir_Kind_Package_Instantiation_Declaration => 515,
+ Iir_Kind_Package_Body => 523,
+ Iir_Kind_Configuration_Declaration => 532,
+ Iir_Kind_Entity_Declaration => 544,
+ Iir_Kind_Architecture_Body => 556,
+ Iir_Kind_Context_Declaration => 562,
+ Iir_Kind_Package_Header => 564,
+ Iir_Kind_Unit_Declaration => 572,
+ Iir_Kind_Library_Declaration => 579,
+ Iir_Kind_Component_Declaration => 589,
+ Iir_Kind_Attribute_Declaration => 596,
+ Iir_Kind_Group_Template_Declaration => 602,
+ Iir_Kind_Group_Declaration => 609,
+ Iir_Kind_Element_Declaration => 617,
+ Iir_Kind_Non_Object_Alias_Declaration => 625,
+ Iir_Kind_Psl_Declaration => 633,
+ Iir_Kind_Psl_Endpoint_Declaration => 647,
+ Iir_Kind_Terminal_Declaration => 653,
+ Iir_Kind_Free_Quantity_Declaration => 662,
+ Iir_Kind_Across_Quantity_Declaration => 674,
+ Iir_Kind_Through_Quantity_Declaration => 686,
+ Iir_Kind_Enumeration_Literal => 697,
+ Iir_Kind_Function_Declaration => 722,
+ Iir_Kind_Procedure_Declaration => 746,
+ Iir_Kind_Function_Body => 756,
+ Iir_Kind_Procedure_Body => 767,
+ Iir_Kind_Object_Alias_Declaration => 778,
+ Iir_Kind_File_Declaration => 792,
+ Iir_Kind_Guard_Signal_Declaration => 805,
+ Iir_Kind_Signal_Declaration => 822,
+ Iir_Kind_Variable_Declaration => 835,
+ Iir_Kind_Constant_Declaration => 849,
+ Iir_Kind_Iterator_Declaration => 860,
+ Iir_Kind_Interface_Constant_Declaration => 876,
+ Iir_Kind_Interface_Variable_Declaration => 892,
+ Iir_Kind_Interface_Signal_Declaration => 913,
+ Iir_Kind_Interface_File_Declaration => 929,
+ Iir_Kind_Interface_Type_Declaration => 939,
+ Iir_Kind_Interface_Package_Declaration => 950,
+ Iir_Kind_Interface_Function_Declaration => 967,
+ Iir_Kind_Interface_Procedure_Declaration => 980,
+ Iir_Kind_Signal_Attribute_Declaration => 983,
+ Iir_Kind_Identity_Operator => 987,
+ Iir_Kind_Negation_Operator => 991,
+ Iir_Kind_Absolute_Operator => 995,
+ Iir_Kind_Not_Operator => 999,
+ Iir_Kind_Condition_Operator => 1003,
+ Iir_Kind_Reduction_And_Operator => 1007,
+ Iir_Kind_Reduction_Or_Operator => 1011,
+ Iir_Kind_Reduction_Nand_Operator => 1015,
+ Iir_Kind_Reduction_Nor_Operator => 1019,
+ Iir_Kind_Reduction_Xor_Operator => 1023,
+ Iir_Kind_Reduction_Xnor_Operator => 1027,
+ Iir_Kind_And_Operator => 1032,
+ Iir_Kind_Or_Operator => 1037,
+ Iir_Kind_Nand_Operator => 1042,
+ Iir_Kind_Nor_Operator => 1047,
+ Iir_Kind_Xor_Operator => 1052,
+ Iir_Kind_Xnor_Operator => 1057,
+ Iir_Kind_Equality_Operator => 1062,
+ Iir_Kind_Inequality_Operator => 1067,
+ Iir_Kind_Less_Than_Operator => 1072,
+ Iir_Kind_Less_Than_Or_Equal_Operator => 1077,
+ Iir_Kind_Greater_Than_Operator => 1082,
+ Iir_Kind_Greater_Than_Or_Equal_Operator => 1087,
+ Iir_Kind_Match_Equality_Operator => 1092,
+ Iir_Kind_Match_Inequality_Operator => 1097,
+ Iir_Kind_Match_Less_Than_Operator => 1102,
+ Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1107,
+ Iir_Kind_Match_Greater_Than_Operator => 1112,
+ Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1117,
+ Iir_Kind_Sll_Operator => 1122,
+ Iir_Kind_Sla_Operator => 1127,
+ Iir_Kind_Srl_Operator => 1132,
+ Iir_Kind_Sra_Operator => 1137,
+ Iir_Kind_Rol_Operator => 1142,
+ Iir_Kind_Ror_Operator => 1147,
+ Iir_Kind_Addition_Operator => 1152,
+ Iir_Kind_Substraction_Operator => 1157,
+ Iir_Kind_Concatenation_Operator => 1162,
+ Iir_Kind_Multiplication_Operator => 1167,
+ Iir_Kind_Division_Operator => 1172,
+ Iir_Kind_Modulus_Operator => 1177,
+ Iir_Kind_Remainder_Operator => 1182,
+ Iir_Kind_Exponentiation_Operator => 1187,
+ Iir_Kind_Function_Call => 1195,
+ Iir_Kind_Aggregate => 1202,
+ Iir_Kind_Parenthesis_Expression => 1205,
+ Iir_Kind_Qualified_Expression => 1209,
+ Iir_Kind_Type_Conversion => 1214,
+ Iir_Kind_Allocator_By_Expression => 1218,
+ Iir_Kind_Allocator_By_Subtype => 1223,
+ Iir_Kind_Selected_Element => 1229,
+ Iir_Kind_Dereference => 1234,
+ Iir_Kind_Implicit_Dereference => 1239,
+ Iir_Kind_Slice_Name => 1246,
+ Iir_Kind_Indexed_Name => 1252,
+ Iir_Kind_Psl_Expression => 1254,
+ Iir_Kind_Sensitized_Process_Statement => 1275,
+ Iir_Kind_Process_Statement => 1295,
+ Iir_Kind_Concurrent_Simple_Signal_Assignment => 1307,
+ Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1319,
+ Iir_Kind_Concurrent_Selected_Signal_Assignment => 1332,
+ Iir_Kind_Concurrent_Assertion_Statement => 1340,
+ Iir_Kind_Concurrent_Procedure_Call_Statement => 1347,
+ Iir_Kind_Psl_Assert_Statement => 1360,
+ Iir_Kind_Psl_Cover_Statement => 1373,
+ Iir_Kind_Block_Statement => 1386,
+ Iir_Kind_If_Generate_Statement => 1397,
+ Iir_Kind_Case_Generate_Statement => 1406,
+ Iir_Kind_For_Generate_Statement => 1415,
+ Iir_Kind_Component_Instantiation_Statement => 1425,
+ Iir_Kind_Psl_Default_Clock => 1429,
+ Iir_Kind_Simple_Simultaneous_Statement => 1436,
+ Iir_Kind_Generate_Statement_Body => 1447,
+ Iir_Kind_If_Generate_Else_Clause => 1453,
+ Iir_Kind_Simple_Signal_Assignment_Statement => 1463,
+ Iir_Kind_Conditional_Signal_Assignment_Statement => 1473,
+ Iir_Kind_Selected_Waveform_Assignment_Statement => 1484,
+ Iir_Kind_Null_Statement => 1488,
+ Iir_Kind_Assertion_Statement => 1495,
+ Iir_Kind_Report_Statement => 1501,
+ Iir_Kind_Wait_Statement => 1509,
+ Iir_Kind_Variable_Assignment_Statement => 1516,
+ Iir_Kind_Conditional_Variable_Assignment_Statement => 1523,
+ Iir_Kind_Return_Statement => 1529,
+ Iir_Kind_For_Loop_Statement => 1538,
+ Iir_Kind_While_Loop_Statement => 1547,
+ Iir_Kind_Next_Statement => 1554,
+ Iir_Kind_Exit_Statement => 1561,
+ Iir_Kind_Case_Statement => 1569,
+ Iir_Kind_Procedure_Call_Statement => 1575,
+ Iir_Kind_If_Statement => 1585,
+ Iir_Kind_Elsif => 1591,
+ Iir_Kind_Character_Literal => 1599,
+ Iir_Kind_Simple_Name => 1607,
+ Iir_Kind_Selected_Name => 1616,
+ Iir_Kind_Operator_Symbol => 1622,
+ Iir_Kind_Reference_Name => 1625,
+ Iir_Kind_Selected_By_All_Name => 1631,
+ Iir_Kind_Parenthesis_Name => 1636,
+ Iir_Kind_External_Constant_Name => 1644,
+ Iir_Kind_External_Signal_Name => 1652,
+ Iir_Kind_External_Variable_Name => 1660,
+ Iir_Kind_Package_Pathname => 1664,
+ Iir_Kind_Absolute_Pathname => 1665,
+ Iir_Kind_Relative_Pathname => 1666,
+ Iir_Kind_Pathname_Element => 1671,
+ Iir_Kind_Base_Attribute => 1673,
+ Iir_Kind_Subtype_Attribute => 1678,
+ Iir_Kind_Element_Attribute => 1683,
+ Iir_Kind_Left_Type_Attribute => 1688,
+ Iir_Kind_Right_Type_Attribute => 1693,
+ Iir_Kind_High_Type_Attribute => 1698,
+ Iir_Kind_Low_Type_Attribute => 1703,
+ Iir_Kind_Ascending_Type_Attribute => 1708,
+ Iir_Kind_Image_Attribute => 1714,
+ Iir_Kind_Value_Attribute => 1720,
+ Iir_Kind_Pos_Attribute => 1726,
+ Iir_Kind_Val_Attribute => 1732,
+ Iir_Kind_Succ_Attribute => 1738,
+ Iir_Kind_Pred_Attribute => 1744,
+ Iir_Kind_Leftof_Attribute => 1750,
+ Iir_Kind_Rightof_Attribute => 1756,
+ Iir_Kind_Delayed_Attribute => 1765,
+ Iir_Kind_Stable_Attribute => 1774,
+ Iir_Kind_Quiet_Attribute => 1783,
+ Iir_Kind_Transaction_Attribute => 1792,
+ Iir_Kind_Event_Attribute => 1796,
+ Iir_Kind_Active_Attribute => 1800,
+ Iir_Kind_Last_Event_Attribute => 1804,
+ Iir_Kind_Last_Active_Attribute => 1808,
+ Iir_Kind_Last_Value_Attribute => 1812,
+ Iir_Kind_Driving_Attribute => 1816,
+ Iir_Kind_Driving_Value_Attribute => 1820,
+ Iir_Kind_Behavior_Attribute => 1820,
+ Iir_Kind_Structure_Attribute => 1820,
+ Iir_Kind_Simple_Name_Attribute => 1827,
+ Iir_Kind_Instance_Name_Attribute => 1832,
+ Iir_Kind_Path_Name_Attribute => 1837,
+ Iir_Kind_Left_Array_Attribute => 1844,
+ Iir_Kind_Right_Array_Attribute => 1851,
+ Iir_Kind_High_Array_Attribute => 1858,
+ Iir_Kind_Low_Array_Attribute => 1865,
+ Iir_Kind_Length_Array_Attribute => 1872,
+ Iir_Kind_Ascending_Array_Attribute => 1879,
+ Iir_Kind_Range_Array_Attribute => 1886,
+ Iir_Kind_Reverse_Range_Array_Attribute => 1893,
+ Iir_Kind_Attribute_Name => 1902
);
function Get_Fields (K : Iir_Kind) return Fields_Array
@@ -4714,6 +4725,8 @@ package body Nodes_Meta is
return Get_Index_Constraint_Flag (N);
when Field_Hide_Implicit_Flag =>
return Get_Hide_Implicit_Flag (N);
+ when Field_In_Formal_Flag =>
+ return Get_In_Formal_Flag (N);
when Field_Aggr_Dynamic_Flag =>
return Get_Aggr_Dynamic_Flag (N);
when Field_Aggr_Others_Flag =>
@@ -4840,6 +4853,8 @@ package body Nodes_Meta is
Set_Index_Constraint_Flag (N, V);
when Field_Hide_Implicit_Flag =>
Set_Hide_Implicit_Flag (N, V);
+ when Field_In_Formal_Flag =>
+ Set_In_Formal_Flag (N, V);
when Field_Aggr_Dynamic_Flag =>
Set_Aggr_Dynamic_Flag (N, V);
when Field_Aggr_Others_Flag =>
@@ -9761,6 +9776,21 @@ package body Nodes_Meta is
return K = Iir_Kind_Pathname_Element;
end Has_Pathname_Expression;
+ function Has_In_Formal_Flag (K : Iir_Kind) return Boolean is
+ begin
+ case K is
+ when Iir_Kind_Association_Element_By_Expression
+ | Iir_Kind_Association_Element_By_Individual
+ | Iir_Kind_Association_Element_Open
+ | Iir_Kind_Association_Element_Package
+ | Iir_Kind_Association_Element_Type
+ | Iir_Kind_Association_Element_Subprogram =>
+ return True;
+ when others =>
+ return False;
+ end case;
+ end Has_In_Formal_Flag;
+
function Has_Slice_Subtype (K : Iir_Kind) return Boolean is
begin
return K = Iir_Kind_Slice_Name;
diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads
index a9da54d68..b25cb3a8b 100644
--- a/src/vhdl/nodes_meta.ads
+++ b/src/vhdl/nodes_meta.ads
@@ -309,6 +309,7 @@ package Nodes_Meta is
Field_External_Pathname,
Field_Pathname_Suffix,
Field_Pathname_Expression,
+ Field_In_Formal_Flag,
Field_Slice_Subtype,
Field_Suffix,
Field_Index_Subtype,
@@ -819,6 +820,7 @@ package Nodes_Meta is
function Has_External_Pathname (K : Iir_Kind) return Boolean;
function Has_Pathname_Suffix (K : Iir_Kind) return Boolean;
function Has_Pathname_Expression (K : Iir_Kind) return Boolean;
+ function Has_In_Formal_Flag (K : Iir_Kind) return Boolean;
function Has_Slice_Subtype (K : Iir_Kind) return Boolean;
function Has_Suffix (K : Iir_Kind) return Boolean;
function Has_Index_Subtype (K : Iir_Kind) return Boolean;
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index f2b0682e1..0422e3471 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -6762,6 +6762,7 @@ package body Parse is
when Iir_Kind_Parenthesis_Name =>
-- Could be an indexed name, so nothing to check within the
-- parenthesis.
+ Set_In_Formal_Flag (Get_Association_Chain (Formal), True);
return Formal;
when Iir_Kind_String_Literal8 =>
-- Operator designator
diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb
index 6bd425d7d..c58e0b0a8 100644
--- a/src/vhdl/sem_assocs.adb
+++ b/src/vhdl/sem_assocs.adb
@@ -391,7 +391,10 @@ package body Sem_Assocs is
-- LRM93 2.1.1
-- The actual designator associated with a formal of
-- class constant must be an expression.
- Check_Read (Actual);
+ -- GHDL: unless this is in a formal_part.
+ if not Get_In_Formal_Flag (Assoc) then
+ Check_Read (Actual);
+ end if;
when others =>
Error_Kind
("check_subprogram_association(3)", Formal_Inter);
@@ -1318,153 +1321,6 @@ package body Sem_Assocs is
Set_Formal (Assoc, Saved_Assoc);
end Revert_Formal_Conversion;
- -- NAME is the formal name of an association, without any conversion
- -- function or type.
- -- Try to analyze NAME with INTERFACE.
- -- In case of success, set PREFIX to the most prefix of NAME and NAME_TYPE
- -- to the type of NAME.
- -- In case of failure, set NAME_TYPE to NULL_IIR.
- procedure Sem_Formal_Name (Name : Iir;
- Inter : Iir;
- Prefix : out Iir;
- Name_Type : out Iir)
- is
- Base_Type : Iir;
- Rec_El : Iir;
- begin
- case Get_Kind (Name) is
- when Iir_Kind_Simple_Name =>
- if Get_Identifier (Name) = Get_Identifier (Inter) then
- Prefix := Name;
- Name_Type := Get_Type (Inter);
- else
- Name_Type := Null_Iir;
- end if;
- return;
- when Iir_Kind_Selected_Name =>
- Sem_Formal_Name (Get_Prefix (Name), Inter, Prefix, Name_Type);
- if Name_Type = Null_Iir then
- return;
- end if;
- Base_Type := Get_Base_Type (Name_Type);
- if Get_Kind (Base_Type) /= Iir_Kind_Record_Type_Definition then
- Name_Type := Null_Iir;
- return;
- end if;
- Rec_El := Find_Name_In_List
- (Get_Elements_Declaration_List (Base_Type),
- Get_Identifier (Name));
- if Rec_El = Null_Iir then
- Name_Type := Null_Iir;
- return;
- end if;
- Name_Type := Get_Type (Rec_El);
- return;
- when Iir_Kind_Parenthesis_Name =>
- -- More difficult: slice or indexed array.
- Sem_Formal_Name (Get_Prefix (Name), Inter, Prefix, Name_Type);
- if Name_Type = Null_Iir then
- return;
- end if;
- Base_Type := Get_Base_Type (Name_Type);
- if Get_Kind (Base_Type) /= Iir_Kind_Array_Type_Definition then
- Name_Type := Null_Iir;
- return;
- end if;
- declare
- Chain : Iir;
- Index_List : Iir_List;
- Idx : Iir;
- begin
- Chain := Get_Association_Chain (Name);
- Index_List := Get_Index_Subtype_List (Base_Type);
- -- Check for matching length.
- if Get_Chain_Length (Chain) /= Get_Nbr_Elements (Index_List)
- then
- Name_Type := Null_Iir;
- return;
- end if;
- if Get_Kind (Chain)
- /= Iir_Kind_Association_Element_By_Expression
- then
- Name_Type := Null_Iir;
- return;
- end if;
- Idx := Get_Actual (Chain);
- if (not Is_Chain_Length_One (Chain))
- or else (Get_Kind (Idx) /= Iir_Kind_Range_Expression
- and then not Is_Range_Attribute_Name (Idx))
- -- FIXME: what about subtype !
- then
- -- Indexed name.
- Name_Type := Get_Element_Subtype (Base_Type);
- return;
- end if;
- -- Slice.
- return;
- end;
- when others =>
- Error_Kind ("sem_formal_name", Name);
- end case;
- end Sem_Formal_Name;
-
- -- Return a type or a list of types for a formal expression FORMAL
- -- corresponding to INTERFACE. Possible cases are:
- -- * FORMAL is the simple name with the same identifier as INTERFACE,
- -- FORMAL_TYPE is set to the type of INTERFACE and CONV_TYPE is set
- -- to NULL_IIR.
- -- * FORMAL is a selected, indexed or slice name whose extreme prefix is
- -- a simple name with the same identifier as INTERFACE, FORMAL_TYPE
- -- is set to the type of the name, and CONV_TYPE is set to NULL_IIR.
- -- * FORMAL is a function call, whose only argument is an
- -- association_element_by_expression, whose actual is a name
- -- whose prefix is the same identifier as INTERFACE (note, since FORMAL
- -- is not analyzed, this is parenthesis name), CONV_TYPE is set to
- -- the type or list of type of return type of conversion functions and
- -- FORMAL_TYPE is set to the type of the name.
- -- * otherwise, FORMAL cannot match INTERFACE and both FORMAL_TYPE and
- -- CONV_TYPE are set to NULL_IIR.
- -- If FINISH is true, the simple name is replaced by INTERFACE.
-
- type Param_Assoc_Type is (None, Open, Individual, Whole);
-
- function Sem_Formal (Formal : Iir; Inter : Iir) return Param_Assoc_Type
- is
- Prefix : Iir;
- Formal_Type : Iir;
- begin
- case Get_Kind (Formal) is
- when Iir_Kind_Simple_Name
- | Iir_Kind_Operator_Symbol =>
- -- Certainly the most common case: FORMAL_NAME => VAL.
- -- It is also the easiest. So, handle it completly now.
- if Get_Identifier (Formal) = Get_Identifier (Inter) then
- Formal_Type := Get_Type (Inter);
- Set_Named_Entity (Formal, Inter);
- Set_Type (Formal, Formal_Type);
- Set_Base_Name (Formal, Inter);
- return Whole;
- end if;
- return None;
- when Iir_Kind_Selected_Name
- | Iir_Kind_Slice_Name
- | Iir_Kind_Parenthesis_Name =>
- null;
- when others =>
- -- Should have been caught by sem_association_list.
- Error_Kind ("sem_formal", Formal);
- end case;
- -- Check for a sub-element.
- Sem_Formal_Name (Formal, Inter, Prefix, Formal_Type);
- if Formal_Type /= Null_Iir then
- Set_Type (Formal, Formal_Type);
- Set_Named_Entity (Prefix, Inter);
- return Individual;
- else
- return None;
- end if;
- end Sem_Formal;
-
function Is_Valid_Conversion
(Func : Iir; Res_Base_Type : Iir; Param_Base_Type : Iir) return Boolean
is
@@ -1577,85 +1433,28 @@ package body Sem_Assocs is
(Conv : Iir; Res_Type : Iir; Param_Type : Iir) return Iir
is
Func : Iir;
- Res : Iir;
begin
if Conv = Null_Iir then
return Null_Iir;
end if;
- Func := Extract_Conversion (Get_Named_Entity (Conv),
- Res_Type, Param_Type, Conv);
- if Func = Null_Iir then
- return Null_Iir;
- end if;
- pragma Assert (Get_Kind (Conv) in Iir_Kinds_Denoting_Name);
- Set_Named_Entity (Conv, Func);
+ Func := Extract_Conversion (Conv, Res_Type, Param_Type, Conv);
- case Get_Kind (Func) is
- when Iir_Kind_Function_Declaration =>
- Res := Create_Iir (Iir_Kind_Function_Call);
- Location_Copy (Res, Conv);
- Set_Implementation (Res, Func);
- Set_Prefix (Res, Conv);
- Set_Base_Name (Res, Res);
- Set_Parameter_Association_Chain (Res, Null_Iir);
- Set_Type (Res, Get_Return_Type (Func));
- Set_Expr_Staticness (Res, None);
- Mark_Subprogram_Used (Func);
- Name_To_Method_Object (Res, Conv);
- when Iir_Kind_Subtype_Declaration
- | Iir_Kind_Type_Declaration =>
- Res := Create_Iir (Iir_Kind_Type_Conversion);
- Location_Copy (Res, Conv);
- Set_Type_Mark (Res, Conv);
- Set_Type (Res, Get_Type (Func));
- Set_Expression (Res, Null_Iir);
- Set_Expr_Staticness (Res, None);
- when others =>
- Error_Kind ("extract_out_conversion", Res);
- end case;
- Xrefs.Xref_Name (Conv);
- return Res;
+ return Func;
end Extract_Out_Conversion;
procedure Sem_Association_Open
(Assoc : Iir;
- Inter : Iir;
Finish : Boolean;
- Match : out Compatibility_Level)
- is
- Formal : Iir;
- Assoc_Kind : Param_Assoc_Type;
+ Match : out Compatibility_Level) is
begin
- Formal := Get_Formal (Assoc);
-
- if Formal /= Null_Iir then
- Assoc_Kind := Sem_Formal (Formal, Inter);
- if Assoc_Kind = None then
- Match := Not_Compatible;
- return;
- end if;
- Set_Whole_Association_Flag (Assoc, Assoc_Kind = Whole);
- if Finish then
- Sem_Name (Formal);
- Formal := Finish_Sem_Name (Formal);
- Set_Formal (Assoc, Formal);
- if Get_Kind (Formal) in Iir_Kinds_Denoting_Name
- and then Is_Error (Get_Named_Entity (Formal))
- then
- Match := Not_Compatible;
- return;
- end if;
-
- -- LRM 4.3.3.2 Associations lists
- -- It is an error if an actual of open is associated with a
- -- formal that is associated individually.
- if Assoc_Kind = Individual then
- Error_Msg_Sem
- (+Assoc, "cannot associate individually with open");
- end if;
+ if Finish then
+ -- LRM 4.3.3.2 Associations lists
+ -- It is an error if an actual of open is associated with a
+ -- formal that is associated individually.
+ if Get_Whole_Association_Flag (Assoc) = False then
+ Error_Msg_Sem
+ (+Assoc, "cannot associate individually with open");
end if;
- else
- Set_Whole_Association_Flag (Assoc, True);
end if;
Match := Fully_Compatible;
end Sem_Association_Open;
@@ -2056,36 +1855,23 @@ package body Sem_Assocs is
procedure Sem_Association_By_Expression
(Assoc : Iir;
Inter : Iir;
+ Formal_Name : Iir;
+ Formal_Conv : Iir;
Finish : Boolean;
Match : out Compatibility_Level)
is
- Formal : Iir;
Formal_Type : Iir;
Actual: Iir;
Out_Conv, In_Conv : Iir;
Expr : Iir;
Res_Type : Iir;
- Assoc_Kind : Param_Assoc_Type;
begin
- Formal := Get_Formal (Assoc);
-
- -- Pre-analyze formal and extract out conversion.
- if Formal /= Null_Iir then
- Assoc_Kind := Sem_Formal (Formal, Inter);
- if Assoc_Kind = None then
- Match := Not_Compatible;
- return;
- end if;
- Set_Whole_Association_Flag (Assoc, Assoc_Kind = Whole);
- Formal := Get_Formal (Assoc);
-
- Out_Conv := Get_Formal_Conversion (Assoc);
+ Out_Conv := Formal_Conv;
+ if Formal_Name /= Null_Iir then
+ Formal_Type := Get_Type (Formal_Name);
else
- Set_Whole_Association_Flag (Assoc, True);
- Out_Conv := Null_Iir;
- Formal := Inter;
+ Formal_Type := Get_Type (Inter);
end if;
- Formal_Type := Get_Type (Formal);
-- Extract conversion from actual.
-- LRM08 6.5.7.1 Association lists
@@ -2195,27 +1981,10 @@ package body Sem_Assocs is
return;
end if;
- -- Analyze formal.
- if Get_Formal (Assoc) /= Null_Iir then
- Set_Type (Formal, Null_Iir);
- Sem_Name (Formal);
- Expr := Get_Named_Entity (Formal);
- if Get_Kind (Expr) = Iir_Kind_Error then
- return;
- end if;
- Formal := Finish_Sem_Name (Formal);
- Set_Formal (Assoc, Formal);
- Formal_Type := Get_Type (Expr);
- if Out_Conv = Null_Iir and In_Conv = Null_Iir then
- Res_Type := Formal_Type;
- end if;
- end if;
-
-- LRM08 6.5.7 Association lists
-- The formal part of a named association element may be in the form of
-- a function call [...] if and only if the formal is an interface
-- object, the mode of the formal is OUT, INOUT, BUFFER or LINKAGE [...]
- Set_Formal_Conversion (Assoc, Out_Conv);
if Out_Conv /= Null_Iir
and then Get_Mode (Inter) = Iir_In_Mode
then
@@ -2301,27 +2070,28 @@ package body Sem_Assocs is
-- This sets MATCH.
procedure Sem_Association (Assoc : Iir;
Inter : Iir;
+ Formal : Iir;
+ Formal_Conv : Iir;
Finish : Boolean;
Match : out Compatibility_Level) is
begin
- case Get_Kind (Assoc) is
- when Iir_Kind_Association_Element_Open =>
- Sem_Association_Open (Assoc, Inter, Finish, Match);
-
- when Iir_Kind_Association_Element_By_Expression =>
- Sem_Association_By_Expression (Assoc, Inter, Finish, Match);
+ case Iir_Kinds_Interface_Declaration (Get_Kind (Inter)) is
+ when Iir_Kinds_Interface_Object_Declaration =>
+ if Get_Kind (Assoc) = Iir_Kind_Association_Element_Open then
+ Sem_Association_Open (Assoc, Finish, Match);
+ else
+ Sem_Association_By_Expression
+ (Assoc, Inter, Formal, Formal_Conv, Finish, Match);
+ end if;
- when Iir_Kind_Association_Element_Package =>
+ when Iir_Kind_Interface_Package_Declaration =>
Sem_Association_Package (Assoc, Inter, Finish, Match);
- when Iir_Kind_Association_Element_Type =>
+ when Iir_Kind_Interface_Type_Declaration =>
Sem_Association_Type (Assoc, Inter, Finish, Match);
- when Iir_Kind_Association_Element_Subprogram =>
+ when Iir_Kinds_Interface_Subprogram_Declaration =>
Sem_Association_Subprogram (Assoc, Inter, Finish, Match);
-
- when others =>
- Error_Kind ("sem_assocation", Assoc);
end case;
end Sem_Association;
@@ -2332,6 +2102,10 @@ package body Sem_Assocs is
Sem_Name_Clean (Get_Formal (Assoc));
end Revert_Sem_Association;
+ pragma Unreferenced (Sem_Formal_Conversion);
+ pragma Unreferenced (Revert_Formal_Conversion);
+ pragma Unreferenced (Revert_Sem_Association);
+
procedure Sem_Association_Chain
(Interface_Chain : Iir;
Assoc_Chain: in out Iir;
@@ -2340,30 +2114,11 @@ package body Sem_Assocs is
Loc : Iir;
Match : out Compatibility_Level)
is
- -- Set POS and INTERFACE to *the* matching interface if any of ASSOC.
- procedure Search_Interface (Assoc : Iir;
- Inter : out Iir;
- Pos : out Integer)
- is
- I_Match : Compatibility_Level;
- begin
- Inter := Interface_Chain;
- Pos := 0;
- while Inter /= Null_Iir loop
- -- Formal assoc is not necessarily a simple name, it may be a
- -- conversion function, or even an indexed or selected name.
- Sem_Association (Assoc, Inter, False, I_Match);
- if I_Match /= Not_Compatible then
- return;
- end if;
- Inter := Get_Chain (Inter);
- Pos := Pos + 1;
- end loop;
- end Search_Interface;
-
Assoc : Iir;
Inter : Iir;
+ type Param_Assoc_Type is (None, Open, Individual, Whole);
+
type Assoc_Array is array (Natural range <>) of Param_Assoc_Type;
Nbr_Inter : constant Natural := Get_Chain_Length (Interface_Chain);
Inter_Matched : Assoc_Array (0 .. Nbr_Inter - 1) := (others => None);
@@ -2373,9 +2128,9 @@ package body Sem_Assocs is
Pos : Integer;
Formal : Iir;
- Interface_1 : Iir;
- Pos_1 : Integer;
- Saved_Assoc : Iir;
+ First_Named_Assoc : Iir;
+ Formal_Name : Iir;
+ Formal_Conv : Iir;
begin
Match := Fully_Compatible;
Has_Individual := False;
@@ -2399,7 +2154,8 @@ package body Sem_Assocs is
Match := Not_Compatible;
return;
end if;
- Sem_Association (Assoc, Inter, Finish, Match);
+ Set_Whole_Association_Flag (Assoc, True);
+ Sem_Association (Assoc, Inter, Null_Iir, Null_Iir, Finish, Match);
if Match = Not_Compatible then
return;
end if;
@@ -2415,12 +2171,40 @@ package body Sem_Assocs is
Assoc := Get_Chain (Assoc);
end loop;
- if Match = Not_Compatible then
- return;
- end if;
-
-- Then association by name.
if Assoc /= Null_Iir then
+ -- Make interfaces visible
+ --
+ -- LRM08 12.3 Visibility
+ -- A declaration is visible by selection at places that are defined
+ -- as follows:
+ -- j) For a formal parameter declaration of a given subprogram
+ -- declaration: at the place of the formal part (before the
+ -- compound delimiter =>) of a named parameter association
+ -- element of a corresponding subprogram call.
+ -- k) For a local generic declaration of a given component
+ -- declaration ...
+ -- l) For a local port declaration of a given component declaration:
+ -- ...
+ -- m) For a formal generic declaration of a given entity declaration:
+ -- ...
+ -- n) For a formal port declaration of a given entity declaration:
+ -- ...
+ -- o) For a formal generic declaration or a formal port declaration
+ -- of a given block statement: ...
+ -- p) For a formal generic declaration of a given package
+ -- declaration: ...
+ -- q) For a formal generic declaration of a given subprogram
+ -- declarations: ...
+ --
+ -- At a place in which a given declaration is visible by selection,
+ -- every declaration with the same designator as the given
+ -- declaration and that would otherwise be directly visible is
+ -- hidden.
+ Sem_Scopes.Open_Declarative_Region;
+ Sem_Scopes.Add_Declarations_From_Interface_Chain (Interface_Chain);
+
+ First_Named_Assoc := Assoc;
loop
if Formal = Null_Iir then
-- Positional after named argument. Already caught by
@@ -2431,132 +2215,182 @@ package body Sem_Assocs is
exit;
end if;
- -- FIXME: directly search the formal if finish is true.
- -- Find the Interface.
+ if Finish then
+ Sem_Name (Formal);
+ else
+ Sem_Name_Soft (Formal);
+ end if;
+ Formal_Name := Get_Named_Entity (Formal);
+ if Is_Error (Formal_Name) then
+ if Finish then
+ -- FIXME: display the name of subprg or component/entity.
+ -- FIXME: fetch the interface (for parenthesis_name).
+ Error_Msg_Sem (+Assoc, "no interface for %n in association",
+ +Get_Formal (Assoc));
+ end if;
+ Match := Not_Compatible;
+ exit;
+ end if;
- -- Try as 'normal' or individual assoc.
- Search_Interface (Assoc, Inter, Pos);
+ -- Extract conversion
+ Formal_Conv := Null_Iir;
+ case Get_Kind (Formal_Name) is
+ when Iir_Kind_Function_Call =>
+ -- Only one actual
+ declare
+ Call_Assoc : constant Iir :=
+ Get_Parameter_Association_Chain (Formal_Name);
+ begin
+ if (Get_Kind (Call_Assoc)
+ /= Iir_Kind_Association_Element_By_Expression)
+ or else Get_Chain (Call_Assoc) /= Null_Iir
+ or else Get_Formal (Call_Assoc) /= Null_Iir
+ or else Get_Actual_Conversion (Call_Assoc) /= Null_Iir
+ then
+ Match := Not_Compatible;
+ exit;
+ end if;
+ Formal_Conv := Formal_Name;
+ Formal_Name := Get_Actual (Call_Assoc);
+ end;
+ when Iir_Kind_Type_Conversion =>
+ Formal_Conv := Formal_Name;
+ Formal_Name := Get_Expression (Formal_Name);
+ when Iir_Kind_Slice_Name
+ | Iir_Kind_Indexed_Name
+ | Iir_Kind_Selected_Element
+ | Iir_Kind_Simple_Name =>
+ null;
+ when others =>
+ Formal_Name := Formal;
+ end case;
+ case Get_Kind (Formal_Name) is
+ when Iir_Kind_Selected_Element
+ | Iir_Kind_Slice_Name
+ | Iir_Kind_Indexed_Name =>
+ Inter := Get_Base_Name (Formal_Name);
+ Set_Whole_Association_Flag (Assoc, False);
+ when Iir_Kind_Simple_Name =>
+ Inter := Get_Named_Entity (Formal_Name);
+ Formal_Name := Inter;
+ Set_Whole_Association_Flag (Assoc, True);
+ when others =>
+ -- Error
+ Match := Not_Compatible;
+ exit;
+ end case;
+ if Get_Kind (Inter) not in Iir_Kinds_Interface_Declaration
+ or else Get_Parent (Inter) /= Get_Parent (Interface_Chain)
+ then
+ Match := Not_Compatible;
+ exit;
+ end if;
- if Get_Kind (Formal) = Iir_Kind_Parenthesis_Name
+ -- LRM 4.3.2.2 Association Lists
+ -- The formal part of a named element association may be
+ -- in the form of a function call, [...], if and only
+ -- if the mode of the formal is OUT, INOUT, BUFFER, or
+ -- LINKAGE, and the actual is not OPEN.
+ if Formal_Conv /= Null_Iir
and then
- Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression
+ (Get_Kind (Inter) not in Iir_Kinds_Interface_Object_Declaration
+ or else Get_Mode (Inter) = Iir_In_Mode)
then
- -- Try as formal conversion, only if the actual is not open
- -- according to LRM08 6.5.7 Association lists.
- Revert_Sem_Association (Assoc);
- Saved_Assoc := Sem_Formal_Conversion (Assoc);
-
- if Saved_Assoc /= Null_Iir then
- -- ASSOC could be interpreted as a formal conversion.
- Search_Interface (Assoc, Interface_1, Pos_1);
- -- LRM 4.3.2.2 Association Lists
- -- The formal part of a named element association may be
- -- in the form of a function call, [...], if and only
- -- if the mode of the formal is OUT, INOUT, BUFFER, or
- -- LINKAGE, and the actual is not OPEN.
- if Interface_1 = Null_Iir
- or else Get_Mode (Interface_1) = Iir_In_Mode
- then
- -- Failed to analyze the out conversion.
- Revert_Formal_Conversion (Assoc, Saved_Assoc);
- Interface_1 := Null_Iir;
- end if;
- else
- Interface_1 := Null_Iir;
+ Match := Not_Compatible;
+ exit;
+ end if;
+
+ -- Find the Interface.
+ declare
+ Inter1 : Iir;
+ begin
+ Inter1 := Interface_Chain;
+ Pos := 0;
+ while Inter1 /= Null_Iir loop
+ exit when Inter = Inter1;
+ Inter1 := Get_Chain (Inter1);
+ Pos := Pos + 1;
+ end loop;
+ if Inter1 = Null_Iir then
+ Match := Not_Compatible;
+ exit;
end if;
+ end;
- if Inter = Null_Iir then
- -- FORMAL cannot be interpreted as an individual assoc.
- if Interface_1 /= Null_Iir then
- -- But can be interpreted as a formal conversion.
- Inter := Interface_1;
- Pos := Pos_1;
-
- if Finish then
- -- Free the now unused parenthesis_name.
- Free_Parenthesis_Name
- (Saved_Assoc, Get_Formal_Conversion (Assoc));
- else
- Revert_Formal_Conversion (Assoc, Saved_Assoc);
- end if;
- end if;
- else
- -- FORMAL cannot be interpreted as an individual assoc.
- if Interface_1 /= Null_Iir then
- -- But also as a formal conversion.
+ Sem_Association
+ (Assoc, Inter, Formal_Name, Formal_Conv, Finish, Match);
+ exit when Match = Not_Compatible;
- -- FIXME: todo.
- raise Internal_Error;
- else
+ if Finish then
+ Formal_Name := Finish_Sem_Name (Formal);
+ case Get_Kind (Formal_Name) is
+ when Iir_Kind_Function_Call =>
+ pragma Assert (Formal_Conv /= Null_Iir);
declare
- I_Match : Compatibility_Level;
+ Conv_Assoc : Iir;
begin
- Sem_Association (Assoc, Inter, False, I_Match);
- pragma Assert (I_Match /= Not_Compatible);
+ Set_Formal_Conversion (Assoc, Formal_Name);
+ Conv_Assoc :=
+ Get_Parameter_Association_Chain (Formal_Name);
+ Set_Formal (Assoc, Get_Actual (Conv_Assoc));
+ Free_Iir (Conv_Assoc);
+ Set_Parameter_Association_Chain
+ (Formal_Name, Null_Iir);
+ -- Name_To_Method_Object (Func, Conv);
end;
- end if;
- end if;
+ when Iir_Kind_Type_Conversion =>
+ pragma Assert (Formal_Conv /= Null_Iir);
+ Set_Formal_Conversion (Assoc, Formal_Name);
+ Set_Formal (Assoc, Get_Expression (Formal_Name));
+ when others =>
+ pragma Assert (Formal_Conv = Null_Iir);
+ Set_Formal (Assoc, Formal_Name);
+ end case;
end if;
- if Inter /= Null_Iir then
- if Get_Whole_Association_Flag (Assoc) then
- -- Whole association.
- Last_Individual := Null_Iir;
- if Inter_Matched (Pos) = None then
- if Get_Kind (Assoc) = Iir_Kind_Association_Element_Open
- then
- Inter_Matched (Pos) := Open;
- else
- Inter_Matched (Pos) := Whole;
- end if;
+ if Get_Whole_Association_Flag (Assoc) then
+ -- Whole association.
+ Last_Individual := Null_Iir;
+ if Inter_Matched (Pos) = None then
+ if Get_Kind (Assoc) = Iir_Kind_Association_Element_Open
+ then
+ Inter_Matched (Pos) := Open;
else
- if Finish then
- Error_Msg_Sem
- (+Assoc, "%n already associated", +Inter);
- end if;
- Match := Not_Compatible;
- exit;
+ Inter_Matched (Pos) := Whole;
end if;
else
- -- Individual association.
- Has_Individual := True;
- if Inter_Matched (Pos) /= Whole then
- if Finish
- and then Inter_Matched (Pos) = Individual
- and then Last_Individual /= Inter
- then
- Error_Msg_Sem
- (+Assoc,
- "non consecutive individual association for %n",
- +Inter);
- Match := Not_Compatible;
- exit;
- end if;
- Last_Individual := Inter;
- Inter_Matched (Pos) := Individual;
- else
- if Finish then
- Error_Msg_Sem
- (+Assoc, "%n already associated", +Inter);
- Match := Not_Compatible;
- exit;
- end if;
+ if Finish then
+ Error_Msg_Sem
+ (+Assoc, "%n already associated", +Inter);
end if;
- end if;
- if Finish then
- Sem_Association (Assoc, Inter, True, Match);
- -- MATCH can be Not_Compatible due to errors.
+ Match := Not_Compatible;
+ exit;
end if;
else
- -- Not found.
- if Finish then
- -- FIXME: display the name of subprg or component/entity.
- -- FIXME: fetch the interface (for parenthesis_name).
- Error_Msg_Sem (+Assoc, "no interface for %n in association",
- +Get_Formal (Assoc));
+ -- Individual association.
+ Has_Individual := True;
+ if Inter_Matched (Pos) /= Whole then
+ if Finish
+ and then Inter_Matched (Pos) = Individual
+ and then Last_Individual /= Inter
+ then
+ Error_Msg_Sem
+ (+Assoc,
+ "non consecutive individual association for %n",
+ +Inter);
+ Match := Not_Compatible;
+ exit;
+ end if;
+ Last_Individual := Inter;
+ Inter_Matched (Pos) := Individual;
+ else
+ if Finish then
+ Error_Msg_Sem
+ (+Assoc, "%n already associated", +Inter);
+ Match := Not_Compatible;
+ exit;
+ end if;
end if;
- Match := Not_Compatible;
- exit;
end if;
Assoc := Get_Chain (Assoc);
@@ -2564,8 +2398,27 @@ package body Sem_Assocs is
Formal := Get_Formal (Assoc);
end loop;
+ Sem_Scopes.Close_Declarative_Region;
+
if Match = Not_Compatible then
- -- FIXME: do a clean-up if FINISH is not set ?
+ -- Clean-up.
+ if not Finish then
+ declare
+ Last_Assoc : constant Iir := Assoc;
+ begin
+ Assoc := First_Named_Assoc;
+ while Assoc /= Null_Iir loop
+ Formal := Get_Formal (Assoc);
+ -- User may have used by position assoc after named
+ -- assocs.
+ if Is_Valid (Formal) then
+ Sem_Name_Clean (Formal);
+ end if;
+ exit when Assoc = Last_Assoc;
+ Assoc := Get_Chain (Assoc);
+ end loop;
+ end;
+ end if;
return;
end if;
end if;
diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb
index d37143a8f..e78cc6ea3 100644
--- a/src/vhdl/sem_names.adb
+++ b/src/vhdl/sem_names.adb
@@ -1269,16 +1269,17 @@ package body Sem_Names is
return True;
end Are_Types_Closely_Related;
- function Sem_Type_Conversion (Loc : Iir; Type_Mark : Iir; Actual : Iir)
- return Iir
+ function Sem_Type_Conversion
+ (Name : Iir; Type_Mark : Iir; Actual : Iir; In_Formal : Boolean)
+ return Iir
is
Conv_Type : constant Iir := Get_Type (Type_Mark);
- Conv: Iir_Type_Conversion;
- Expr: Iir;
+ Conv : Iir_Type_Conversion;
+ Expr : Iir;
Staticness : Iir_Staticness;
begin
Conv := Create_Iir (Iir_Kind_Type_Conversion);
- Location_Copy (Conv, Loc);
+ Location_Copy (Conv, Name);
Set_Type_Mark (Conv, Type_Mark);
Set_Type (Conv, Conv_Type);
Set_Expression (Conv, Actual);
@@ -1356,7 +1357,11 @@ package body Sem_Names is
-- Avoid error storm in evaluation.
Set_Expr_Staticness (Conv, None);
else
- Check_Read (Expr);
+ -- Unless the type conversion appears in the formal part of an
+ -- association, the expression must be readable.
+ if not In_Formal then
+ Check_Read (Expr);
+ end if;
end if;
end if;
return Conv;
@@ -2538,16 +2543,23 @@ package body Sem_Names is
Iir_Kind_Subtype_Declaration)
then
-- A type conversion. The prefix is a type mark.
+ declare
+ In_Formal : Boolean;
+ begin
+ if Actual = Null_Iir then
+ -- More than one actual. Keep only the first.
+ Error_Msg_Sem
+ (+Name, "type conversion allows only one expression");
+ In_Formal := False;
+ else
+ In_Formal := Get_In_Formal_Flag (Assoc_Chain);
+ end if;
- if Actual = Null_Iir then
- -- More than one actual. Keep only the first.
- Error_Msg_Sem
- (+Name, "type conversion allows only one expression");
- end if;
-
- -- This is certainly the easiest case: the prefix is not overloaded,
- -- so the result can be computed.
- Set_Named_Entity (Name, Sem_Type_Conversion (Name, Prefix, Actual));
+ -- This is certainly the easiest case: the prefix is not
+ -- overloaded, so the result can be computed.
+ Set_Named_Entity
+ (Name, Sem_Type_Conversion (Name, Prefix, Actual, In_Formal));
+ end;
return;
end if;
diff --git a/src/vhdl/sem_names.ads b/src/vhdl/sem_names.ads
index a85d595cb..636dc884e 100644
--- a/src/vhdl/sem_names.ads
+++ b/src/vhdl/sem_names.ads
@@ -67,7 +67,7 @@ package Sem_Names is
-- * do not set xrefs
-- Currently, only simple names (and expanded names) are handled.
-- This is to be used during sem of associations. Because there is no side
- -- effect, NAME is not modified.
+ -- effect, NAME is not modified (but is decorated with Named_Entity)
procedure Sem_Name_Soft (Name : Iir);
-- Remove every named_entity of NAME.