diff options
author | Tristan Gingold | 2015-05-26 21:28:30 +0200 |
---|---|---|
committer | Tristan Gingold | 2015-05-26 21:28:30 +0200 |
commit | 2f1b14b847d87954b76feebd2d8f683e5ce92fd7 (patch) | |
tree | 2cbecf0822ed332f27bd3c3d09a37b2aa8fcd1f9 | |
parent | fca8226fb65a446ebbe35f7db89384b49a93b510 (diff) | |
download | ghdl-2f1b14b847d87954b76feebd2d8f683e5ce92fd7.tar.gz ghdl-2f1b14b847d87954b76feebd2d8f683e5ce92fd7.tar.bz2 ghdl-2f1b14b847d87954b76feebd2d8f683e5ce92fd7.zip |
Rework of overload resolution in implicit conversions.
Fix tiket 81.
-rw-r--r-- | src/vhdl/iirs.adb | 16 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 9 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 209 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/sem_expr.adb | 6 | ||||
-rw-r--r-- | src/vhdl/sem_names.adb | 15 |
6 files changed, 110 insertions, 147 deletions
diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 609d9fd..ac25a83 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -4026,22 +4026,6 @@ package body Iirs is Set_State1 (Target, Iir_Staticness'Pos (Static)); end Set_Expr_Staticness; - function Get_Has_Implicit_Conversion (Expr : Iir) return Boolean is - begin - pragma Assert (Expr /= Null_Iir); - pragma Assert (Has_Has_Implicit_Conversion (Get_Kind (Expr)), - "no field Has_Implicit_Conversion"); - return Get_Flag1 (Expr); - end Get_Has_Implicit_Conversion; - - procedure Set_Has_Implicit_Conversion (Expr : Iir; Flag : Boolean) is - begin - pragma Assert (Expr /= Null_Iir); - pragma Assert (Has_Has_Implicit_Conversion (Get_Kind (Expr)), - "no field Has_Implicit_Conversion"); - Set_Flag1 (Expr, Flag); - end Set_Has_Implicit_Conversion; - function Get_Error_Origin (Target : Iir) return Iir is begin pragma Assert (Target /= Null_Iir); diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index e8a1b74..0db83ca 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -2980,8 +2980,6 @@ package Iirs is -- Get/Set_Expr_Staticness (State1) -- -- Get/Set_Name_Staticness (State2) - -- - -- Get/Set_Has_Implicit_Conversion (Flag1) -- Iir_Kind_Aggregate (Short) -- @@ -6142,13 +6140,6 @@ package Iirs is function Get_Expr_Staticness (Target : Iir) return Iir_Staticness; procedure Set_Expr_Staticness (Target : Iir; Static : Iir_Staticness); - -- Set when EXPR has implicit conversion in its sub-tree. This is used - -- only during analysis for overload resolution (see LRM08 9.3.6 Type - -- conversions). - -- Field: Flag1 - function Get_Has_Implicit_Conversion (Expr : Iir) return Boolean; - procedure Set_Has_Implicit_Conversion (Expr : Iir; Flag : Boolean); - -- Node which couldn't be correctly analyzed. -- Field: Field2 function Get_Error_Origin (Target : Iir) return Iir; diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index cbe86fb..c935825 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -238,7 +238,6 @@ package body Nodes_Meta is Field_Named_Entity => Type_Iir, Field_Alias_Declaration => Type_Iir, Field_Expr_Staticness => Type_Iir_Staticness, - Field_Has_Implicit_Conversion => Type_Boolean, Field_Error_Origin => Type_Iir, Field_Operand => Type_Iir, Field_Left => Type_Iir, @@ -763,8 +762,6 @@ package body Nodes_Meta is return "alias_declaration"; when Field_Expr_Staticness => return "expr_staticness"; - when Field_Has_Implicit_Conversion => - return "has_implicit_conversion"; when Field_Error_Origin => return "error_origin"; when Field_Operand => @@ -1865,8 +1862,6 @@ package body Nodes_Meta is return Attr_None; when Field_Expr_Staticness => return Attr_None; - when Field_Has_Implicit_Conversion => - return Attr_None; when Field_Error_Origin => return Attr_None; when Field_Operand => @@ -3238,7 +3233,6 @@ package body Nodes_Meta is Field_Type, Field_Implementation, -- Iir_Kind_Function_Call - Field_Has_Implicit_Conversion, Field_Expr_Staticness, Field_Name_Staticness, Field_Prefix, @@ -3683,7 +3677,6 @@ package body Nodes_Meta is Field_Identifier, Field_Pathname_Suffix, Field_Named_Entity, - Field_Base_Name, -- Iir_Kind_Absolute_Pathname Field_Pathname_Suffix, -- Iir_Kind_Relative_Pathname @@ -4105,102 +4098,102 @@ package body Nodes_Meta is Iir_Kind_Modulus_Operator => 1049, Iir_Kind_Remainder_Operator => 1054, Iir_Kind_Exponentiation_Operator => 1059, - Iir_Kind_Function_Call => 1068, - Iir_Kind_Aggregate => 1074, - Iir_Kind_Parenthesis_Expression => 1077, - Iir_Kind_Qualified_Expression => 1081, - Iir_Kind_Type_Conversion => 1086, - Iir_Kind_Allocator_By_Expression => 1090, - Iir_Kind_Allocator_By_Subtype => 1094, - Iir_Kind_Selected_Element => 1100, - Iir_Kind_Dereference => 1105, - Iir_Kind_Implicit_Dereference => 1110, - Iir_Kind_Slice_Name => 1117, - Iir_Kind_Indexed_Name => 1123, - Iir_Kind_Psl_Expression => 1125, - Iir_Kind_Sensitized_Process_Statement => 1145, - Iir_Kind_Process_Statement => 1164, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1175, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1187, - Iir_Kind_Concurrent_Assertion_Statement => 1195, - Iir_Kind_Psl_Default_Clock => 1199, - Iir_Kind_Psl_Assert_Statement => 1208, - Iir_Kind_Psl_Cover_Statement => 1217, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1223, - Iir_Kind_Block_Statement => 1236, - Iir_Kind_If_Generate_Statement => 1246, - Iir_Kind_For_Generate_Statement => 1255, - Iir_Kind_Component_Instantiation_Statement => 1265, - Iir_Kind_Simple_Simultaneous_Statement => 1272, - Iir_Kind_Generate_Statement_Body => 1283, - Iir_Kind_If_Generate_Else_Clause => 1288, - Iir_Kind_Signal_Assignment_Statement => 1297, - Iir_Kind_Null_Statement => 1301, - Iir_Kind_Assertion_Statement => 1308, - Iir_Kind_Report_Statement => 1314, - Iir_Kind_Wait_Statement => 1321, - Iir_Kind_Variable_Assignment_Statement => 1327, - Iir_Kind_Return_Statement => 1333, - Iir_Kind_For_Loop_Statement => 1341, - Iir_Kind_While_Loop_Statement => 1348, - Iir_Kind_Next_Statement => 1354, - Iir_Kind_Exit_Statement => 1360, - Iir_Kind_Case_Statement => 1367, - Iir_Kind_Procedure_Call_Statement => 1372, - Iir_Kind_If_Statement => 1380, - Iir_Kind_Elsif => 1385, - Iir_Kind_Character_Literal => 1392, - Iir_Kind_Simple_Name => 1399, - Iir_Kind_Selected_Name => 1407, - Iir_Kind_Operator_Symbol => 1412, - Iir_Kind_Selected_By_All_Name => 1417, - Iir_Kind_Parenthesis_Name => 1421, - Iir_Kind_External_Constant_Name => 1430, - Iir_Kind_External_Signal_Name => 1439, - Iir_Kind_External_Variable_Name => 1448, - Iir_Kind_Package_Pathname => 1452, - Iir_Kind_Absolute_Pathname => 1453, - Iir_Kind_Relative_Pathname => 1454, - Iir_Kind_Pathname_Element => 1458, - Iir_Kind_Base_Attribute => 1460, - Iir_Kind_Left_Type_Attribute => 1465, - Iir_Kind_Right_Type_Attribute => 1470, - Iir_Kind_High_Type_Attribute => 1475, - Iir_Kind_Low_Type_Attribute => 1480, - Iir_Kind_Ascending_Type_Attribute => 1485, - Iir_Kind_Image_Attribute => 1491, - Iir_Kind_Value_Attribute => 1497, - Iir_Kind_Pos_Attribute => 1503, - Iir_Kind_Val_Attribute => 1509, - Iir_Kind_Succ_Attribute => 1515, - Iir_Kind_Pred_Attribute => 1521, - Iir_Kind_Leftof_Attribute => 1527, - Iir_Kind_Rightof_Attribute => 1533, - Iir_Kind_Delayed_Attribute => 1541, - Iir_Kind_Stable_Attribute => 1549, - Iir_Kind_Quiet_Attribute => 1557, - Iir_Kind_Transaction_Attribute => 1565, - Iir_Kind_Event_Attribute => 1569, - Iir_Kind_Active_Attribute => 1573, - Iir_Kind_Last_Event_Attribute => 1577, - Iir_Kind_Last_Active_Attribute => 1581, - Iir_Kind_Last_Value_Attribute => 1585, - Iir_Kind_Driving_Attribute => 1589, - Iir_Kind_Driving_Value_Attribute => 1593, - Iir_Kind_Behavior_Attribute => 1593, - Iir_Kind_Structure_Attribute => 1593, - Iir_Kind_Simple_Name_Attribute => 1600, - Iir_Kind_Instance_Name_Attribute => 1605, - Iir_Kind_Path_Name_Attribute => 1610, - Iir_Kind_Left_Array_Attribute => 1617, - Iir_Kind_Right_Array_Attribute => 1624, - Iir_Kind_High_Array_Attribute => 1631, - Iir_Kind_Low_Array_Attribute => 1638, - Iir_Kind_Length_Array_Attribute => 1645, - Iir_Kind_Ascending_Array_Attribute => 1652, - Iir_Kind_Range_Array_Attribute => 1659, - Iir_Kind_Reverse_Range_Array_Attribute => 1666, - Iir_Kind_Attribute_Name => 1674 + Iir_Kind_Function_Call => 1067, + Iir_Kind_Aggregate => 1073, + Iir_Kind_Parenthesis_Expression => 1076, + Iir_Kind_Qualified_Expression => 1080, + Iir_Kind_Type_Conversion => 1085, + Iir_Kind_Allocator_By_Expression => 1089, + Iir_Kind_Allocator_By_Subtype => 1093, + Iir_Kind_Selected_Element => 1099, + Iir_Kind_Dereference => 1104, + Iir_Kind_Implicit_Dereference => 1109, + Iir_Kind_Slice_Name => 1116, + Iir_Kind_Indexed_Name => 1122, + Iir_Kind_Psl_Expression => 1124, + Iir_Kind_Sensitized_Process_Statement => 1144, + Iir_Kind_Process_Statement => 1163, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1174, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1186, + Iir_Kind_Concurrent_Assertion_Statement => 1194, + Iir_Kind_Psl_Default_Clock => 1198, + Iir_Kind_Psl_Assert_Statement => 1207, + Iir_Kind_Psl_Cover_Statement => 1216, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1222, + Iir_Kind_Block_Statement => 1235, + Iir_Kind_If_Generate_Statement => 1245, + Iir_Kind_For_Generate_Statement => 1254, + Iir_Kind_Component_Instantiation_Statement => 1264, + Iir_Kind_Simple_Simultaneous_Statement => 1271, + Iir_Kind_Generate_Statement_Body => 1282, + Iir_Kind_If_Generate_Else_Clause => 1287, + Iir_Kind_Signal_Assignment_Statement => 1296, + Iir_Kind_Null_Statement => 1300, + Iir_Kind_Assertion_Statement => 1307, + Iir_Kind_Report_Statement => 1313, + Iir_Kind_Wait_Statement => 1320, + Iir_Kind_Variable_Assignment_Statement => 1326, + Iir_Kind_Return_Statement => 1332, + Iir_Kind_For_Loop_Statement => 1340, + Iir_Kind_While_Loop_Statement => 1347, + Iir_Kind_Next_Statement => 1353, + Iir_Kind_Exit_Statement => 1359, + Iir_Kind_Case_Statement => 1366, + Iir_Kind_Procedure_Call_Statement => 1371, + Iir_Kind_If_Statement => 1379, + Iir_Kind_Elsif => 1384, + Iir_Kind_Character_Literal => 1391, + Iir_Kind_Simple_Name => 1398, + Iir_Kind_Selected_Name => 1406, + Iir_Kind_Operator_Symbol => 1411, + Iir_Kind_Selected_By_All_Name => 1416, + Iir_Kind_Parenthesis_Name => 1420, + Iir_Kind_External_Constant_Name => 1429, + Iir_Kind_External_Signal_Name => 1438, + Iir_Kind_External_Variable_Name => 1447, + Iir_Kind_Package_Pathname => 1450, + Iir_Kind_Absolute_Pathname => 1451, + Iir_Kind_Relative_Pathname => 1452, + Iir_Kind_Pathname_Element => 1456, + Iir_Kind_Base_Attribute => 1458, + Iir_Kind_Left_Type_Attribute => 1463, + Iir_Kind_Right_Type_Attribute => 1468, + Iir_Kind_High_Type_Attribute => 1473, + Iir_Kind_Low_Type_Attribute => 1478, + Iir_Kind_Ascending_Type_Attribute => 1483, + Iir_Kind_Image_Attribute => 1489, + Iir_Kind_Value_Attribute => 1495, + Iir_Kind_Pos_Attribute => 1501, + Iir_Kind_Val_Attribute => 1507, + Iir_Kind_Succ_Attribute => 1513, + Iir_Kind_Pred_Attribute => 1519, + Iir_Kind_Leftof_Attribute => 1525, + Iir_Kind_Rightof_Attribute => 1531, + Iir_Kind_Delayed_Attribute => 1539, + Iir_Kind_Stable_Attribute => 1547, + Iir_Kind_Quiet_Attribute => 1555, + Iir_Kind_Transaction_Attribute => 1563, + Iir_Kind_Event_Attribute => 1567, + Iir_Kind_Active_Attribute => 1571, + Iir_Kind_Last_Event_Attribute => 1575, + Iir_Kind_Last_Active_Attribute => 1579, + Iir_Kind_Last_Value_Attribute => 1583, + Iir_Kind_Driving_Attribute => 1587, + Iir_Kind_Driving_Value_Attribute => 1591, + Iir_Kind_Behavior_Attribute => 1591, + Iir_Kind_Structure_Attribute => 1591, + Iir_Kind_Simple_Name_Attribute => 1598, + Iir_Kind_Instance_Name_Attribute => 1603, + Iir_Kind_Path_Name_Attribute => 1608, + Iir_Kind_Left_Array_Attribute => 1615, + Iir_Kind_Right_Array_Attribute => 1622, + Iir_Kind_High_Array_Attribute => 1629, + Iir_Kind_Low_Array_Attribute => 1636, + Iir_Kind_Length_Array_Attribute => 1643, + Iir_Kind_Ascending_Array_Attribute => 1650, + Iir_Kind_Range_Array_Attribute => 1657, + Iir_Kind_Reverse_Range_Array_Attribute => 1664, + Iir_Kind_Attribute_Name => 1672 ); function Get_Fields (K : Iir_Kind) return Fields_Array @@ -4300,8 +4293,6 @@ package body Nodes_Meta is return Get_Elab_Flag (N); when Field_Index_Constraint_Flag => return Get_Index_Constraint_Flag (N); - when Field_Has_Implicit_Conversion => - return Get_Has_Implicit_Conversion (N); when Field_Aggr_Dynamic_Flag => return Get_Aggr_Dynamic_Flag (N); when Field_Aggr_Others_Flag => @@ -4408,8 +4399,6 @@ package body Nodes_Meta is Set_Elab_Flag (N, V); when Field_Index_Constraint_Flag => Set_Index_Constraint_Flag (N, V); - when Field_Has_Implicit_Conversion => - Set_Has_Implicit_Conversion (N, V); when Field_Aggr_Dynamic_Flag => Set_Aggr_Dynamic_Flag (N, V); when Field_Aggr_Others_Flag => @@ -6930,7 +6919,6 @@ package body Nodes_Meta is | Iir_Kind_Selected_Name | Iir_Kind_Operator_Symbol | Iir_Kind_Selected_By_All_Name - | Iir_Kind_Package_Pathname | Iir_Kind_Left_Type_Attribute | Iir_Kind_Right_Type_Attribute | Iir_Kind_High_Type_Attribute @@ -8653,11 +8641,6 @@ package body Nodes_Meta is end case; end Has_Expr_Staticness; - function Has_Has_Implicit_Conversion (K : Iir_Kind) return Boolean is - begin - return K = Iir_Kind_Function_Call; - end Has_Has_Implicit_Conversion; - function Has_Error_Origin (K : Iir_Kind) return Boolean is begin return K = Iir_Kind_Error; diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads index 5c740b5..ce1d33c 100644 --- a/src/vhdl/nodes_meta.ads +++ b/src/vhdl/nodes_meta.ads @@ -278,7 +278,6 @@ package Nodes_Meta is Field_Named_Entity, Field_Alias_Declaration, Field_Expr_Staticness, - Field_Has_Implicit_Conversion, Field_Error_Origin, Field_Operand, Field_Left, @@ -762,7 +761,6 @@ package Nodes_Meta is function Has_Named_Entity (K : Iir_Kind) return Boolean; function Has_Alias_Declaration (K : Iir_Kind) return Boolean; function Has_Expr_Staticness (K : Iir_Kind) return Boolean; - function Has_Has_Implicit_Conversion (K : Iir_Kind) return Boolean; function Has_Error_Origin (K : Iir_Kind) return Boolean; function Has_Operand (K : Iir_Kind) return Boolean; function Has_Left (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index bbc9aaa..8a7239a 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -1587,11 +1587,7 @@ package body Sem_Expr is -- -- If there are two functions, one primitive of a universal -- type and the other not, return the primitive of the universal type. - -- This rule is *not* from LRM (but from Ada) and allows to resolve - -- common cases such as: - -- constant c1 : integer := - 4; -- or '+', 'abs' - -- constant c2 : integer := 2 ** 3; - -- constant c3 : integer := 3 - 2; -- or '+', '*', '/'... + -- This implements implicit type conversions rules. function Get_Non_Implicit_Subprogram (List : Iir_List) return Iir is El : Iir; diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb index 478499d..5f3854a 100644 --- a/src/vhdl/sem_names.adb +++ b/src/vhdl/sem_names.adb @@ -187,13 +187,25 @@ package body Sem_Names is List : constant Iir_List := Get_Overload_List (Res); Call : Iir; El : Iir; + Imp : Iir; + Inter : Iir; begin Call := Null_Iir; for I in Natural loop El := Get_Nth_Element (List, I); exit when El = Null_Iir; if Get_Kind (El) = Iir_Kind_Function_Call then - if not Get_Has_Implicit_Conversion (El) then + Imp := Get_Implementation (El); + Inter := Get_Interface_Declaration_Chain (Imp); + if Get_Type (Inter) = Universal_Integer_Type_Definition + or else Get_Type (Inter) = Universal_Real_Type_Definition + then + -- The type of the first interface is a universal type. So, + -- there were no implicit conversions. Once there is an + -- implicit conversion, the only way to 'convert' to a + -- universal type is through T'Pos, which has to be resolved. + -- Note: there are no interface of convertible types. + -- GHDL: this is not proven... if Call /= Null_Iir then -- More than one call without implicit conversion. return Null_Iir; @@ -2285,7 +2297,6 @@ package body Sem_Names is if Match /= Not_Compatible then Call := Sem_As_Function_Call (Prefix_Name, Sub_Name, Assoc_Chain); - Set_Has_Implicit_Conversion (Call, Match = Via_Conversion); Add_Result (Res, Call); Used := True; end if; |