Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/sem_ch4.adb @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
4 -- -- | 4 -- -- |
5 -- S E M _ C H 4 -- | 5 -- S E M _ C H 4 -- |
6 -- -- | 6 -- -- |
7 -- B o d y -- | 7 -- B o d y -- |
8 -- -- | 8 -- -- |
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- | 9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. -- |
10 -- -- | 10 -- -- |
11 -- GNAT is free software; you can redistribute it and/or modify it under -- | 11 -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 -- terms of the GNU General Public License as published by the Free Soft- -- | 12 -- terms of the GNU General Public License as published by the Free Soft- -- |
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- | 13 -- ware Foundation; either version 3, or (at your option) any later ver- -- |
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
337 -------------------------- | 337 -------------------------- |
338 -- List_Operand_Interps -- | 338 -- List_Operand_Interps -- |
339 -------------------------- | 339 -------------------------- |
340 | 340 |
341 procedure List_Operand_Interps (Opnd : Node_Id) is | 341 procedure List_Operand_Interps (Opnd : Node_Id) is |
342 Nam : Node_Id; | 342 Nam : Node_Id := Empty; |
343 pragma Warnings (Off, Nam); | 343 Err : Node_Id := N; |
344 Err : Node_Id := N; | |
345 | 344 |
346 begin | 345 begin |
347 if Is_Overloaded (Opnd) then | 346 if Is_Overloaded (Opnd) then |
348 if Nkind (Opnd) in N_Op then | 347 if Nkind (Opnd) in N_Op then |
349 Nam := Opnd; | 348 Nam := Opnd; |
411 | 410 |
412 ----------------------- | 411 ----------------------- |
413 -- Analyze_Aggregate -- | 412 -- Analyze_Aggregate -- |
414 ----------------------- | 413 ----------------------- |
415 | 414 |
416 -- Most of the analysis of Aggregates requires that the type be known, | 415 -- Most of the analysis of Aggregates requires that the type be known, and |
417 -- and is therefore put off until resolution. | 416 -- is therefore put off until resolution of the context. Delta aggregates |
417 -- have a base component that determines the enclosing aggregate type so | |
418 -- its type can be ascertained earlier. This also allows delta aggregates | |
419 -- to appear in the context of a record type with a private extension, as | |
420 -- per the latest update of AI12-0127. | |
418 | 421 |
419 procedure Analyze_Aggregate (N : Node_Id) is | 422 procedure Analyze_Aggregate (N : Node_Id) is |
420 begin | 423 begin |
421 if No (Etype (N)) then | 424 if No (Etype (N)) then |
422 Set_Etype (N, Any_Composite); | 425 if Nkind (N) = N_Delta_Aggregate then |
426 declare | |
427 Base : constant Node_Id := Expression (N); | |
428 | |
429 I : Interp_Index; | |
430 It : Interp; | |
431 | |
432 begin | |
433 Analyze (Base); | |
434 | |
435 -- If the base is overloaded, propagate interpretations to the | |
436 -- enclosing aggregate. | |
437 | |
438 if Is_Overloaded (Base) then | |
439 Get_First_Interp (Base, I, It); | |
440 Set_Etype (N, Any_Type); | |
441 | |
442 while Present (It.Nam) loop | |
443 Add_One_Interp (N, It.Typ, It.Typ); | |
444 Get_Next_Interp (I, It); | |
445 end loop; | |
446 | |
447 else | |
448 Set_Etype (N, Etype (Base)); | |
449 end if; | |
450 end; | |
451 | |
452 else | |
453 Set_Etype (N, Any_Composite); | |
454 end if; | |
423 end if; | 455 end if; |
424 end Analyze_Aggregate; | 456 end Analyze_Aggregate; |
425 | 457 |
426 ----------------------- | 458 ----------------------- |
427 -- Analyze_Allocator -- | 459 -- Analyze_Allocator -- |
1041 -- construct where the out-mode actuals of this function may | 1073 -- construct where the out-mode actuals of this function may |
1042 -- introduce conflicts. | 1074 -- introduce conflicts. |
1043 | 1075 |
1044 else | 1076 else |
1045 declare | 1077 declare |
1046 Outermost : Node_Id; | 1078 Outermost : Node_Id := Empty; -- init to avoid warning |
1047 P : Node_Id := N; | 1079 P : Node_Id := N; |
1048 | 1080 |
1049 begin | 1081 begin |
1050 while Present (P) loop | 1082 while Present (P) loop |
1051 | |
1052 -- For object declarations we can climb to the node from | 1083 -- For object declarations we can climb to the node from |
1053 -- its object definition branch or from its initializing | 1084 -- its object definition branch or from its initializing |
1054 -- expression. We prefer to mark the child node as the | 1085 -- expression. We prefer to mark the child node as the |
1055 -- outermost construct to avoid adding further complexity | 1086 -- outermost construct to avoid adding further complexity |
1056 -- to the routine that will later take care of | 1087 -- to the routine that will later take care of |
1061 N_Object_Declaration) | 1092 N_Object_Declaration) |
1062 then | 1093 then |
1063 Outermost := P; | 1094 Outermost := P; |
1064 end if; | 1095 end if; |
1065 | 1096 |
1066 -- Avoid climbing more than needed! | 1097 -- Avoid climbing more than needed |
1067 | 1098 |
1068 exit when Stop_Subtree_Climbing (Nkind (P)) | 1099 exit when Stop_Subtree_Climbing (Nkind (P)) |
1069 or else (Nkind (P) = N_Range | 1100 or else (Nkind (P) = N_Range |
1070 and then not | 1101 and then not |
1071 Nkind_In (Parent (P), N_In, N_Not_In)); | 1102 Nkind_In (Parent (P), N_In, N_Not_In)); |
1312 | 1343 |
1313 -- If the call has been rewritten from a prefixed call, the first | 1344 -- If the call has been rewritten from a prefixed call, the first |
1314 -- parameter has been analyzed, but may need a subsequent | 1345 -- parameter has been analyzed, but may need a subsequent |
1315 -- dereference, so skip its analysis now. | 1346 -- dereference, so skip its analysis now. |
1316 | 1347 |
1317 if N /= Original_Node (N) | 1348 if Is_Rewrite_Substitution (N) |
1318 and then Nkind (Original_Node (N)) = Nkind (N) | 1349 and then Nkind (Original_Node (N)) = Nkind (N) |
1319 and then Nkind (Name (N)) /= Nkind (Name (Original_Node (N))) | 1350 and then Nkind (Name (N)) /= Nkind (Name (Original_Node (N))) |
1320 and then Present (Parameter_Associations (N)) | 1351 and then Present (Parameter_Associations (N)) |
1321 and then Present (Etype (First (Parameter_Associations (N)))) | 1352 and then Present (Etype (First (Parameter_Associations (N)))) |
1322 then | 1353 then |
1486 | 1517 |
1487 elsif From_Limited_With (Etype (N)) | 1518 elsif From_Limited_With (Etype (N)) |
1488 and then Present (Non_Limited_View (Etype (N))) | 1519 and then Present (Non_Limited_View (Etype (N))) |
1489 then | 1520 then |
1490 Set_Etype (N, Non_Limited_View (Etype (N))); | 1521 Set_Etype (N, Non_Limited_View (Etype (N))); |
1522 | |
1523 -- If there is no completion for the type, this may be because | |
1524 -- there is only a limited view of it and there is nothing in | |
1525 -- the context of the current unit that has required a regular | |
1526 -- compilation of the unit containing the type. We recognize | |
1527 -- this unusual case by the fact that that unit is not analyzed. | |
1528 -- Note that the call being analyzed is in a different unit from | |
1529 -- the function declaration, and nothing indicates that the type | |
1530 -- is a limited view. | |
1531 | |
1532 elsif Ekind (Scope (Etype (N))) = E_Package | |
1533 and then Present (Limited_View (Scope (Etype (N)))) | |
1534 and then not Analyzed (Unit_Declaration_Node (Scope (Etype (N)))) | |
1535 then | |
1536 Error_Msg_NE | |
1537 ("cannot call function that returns limited view of}", | |
1538 N, Etype (N)); | |
1539 | |
1540 Error_Msg_NE | |
1541 ("\there must be a regular with_clause for package & in the " | |
1542 & "current unit, or in some unit in its context", | |
1543 N, Scope (Etype (N))); | |
1544 | |
1545 Set_Etype (N, Any_Type); | |
1491 end if; | 1546 end if; |
1492 end if; | 1547 end if; |
1493 end if; | 1548 end if; |
1494 end Analyze_Call; | 1549 end Analyze_Call; |
1495 | 1550 |
1665 -- Call Analyze_Choices and Check_Choices to do the rest of the work | 1720 -- Call Analyze_Choices and Check_Choices to do the rest of the work |
1666 | 1721 |
1667 else | 1722 else |
1668 Analyze_Choices (Alternatives (N), Exp_Type); | 1723 Analyze_Choices (Alternatives (N), Exp_Type); |
1669 Check_Choices (N, Alternatives (N), Exp_Type, Others_Present); | 1724 Check_Choices (N, Alternatives (N), Exp_Type, Others_Present); |
1670 end if; | 1725 |
1671 | 1726 if Exp_Type = Universal_Integer and then not Others_Present then |
1672 if Exp_Type = Universal_Integer and then not Others_Present then | 1727 Error_Msg_N |
1673 Error_Msg_N | 1728 ("case on universal integer requires OTHERS choice", Expr); |
1674 ("case on universal integer requires OTHERS choice", Expr); | 1729 end if; |
1675 end if; | 1730 end if; |
1676 end Analyze_Case_Expression; | 1731 end Analyze_Case_Expression; |
1677 | 1732 |
1678 --------------------------- | 1733 --------------------------- |
1679 -- Analyze_Comparison_Op -- | 1734 -- Analyze_Comparison_Op -- |
2973 -- Start of processing for Analyze_Membership_Op | 3028 -- Start of processing for Analyze_Membership_Op |
2974 | 3029 |
2975 begin | 3030 begin |
2976 Analyze_Expression (L); | 3031 Analyze_Expression (L); |
2977 | 3032 |
2978 if No (R) and then Ada_Version >= Ada_2012 then | 3033 if No (R) then |
3034 pragma Assert (Ada_Version >= Ada_2012); | |
2979 Analyze_Set_Membership; | 3035 Analyze_Set_Membership; |
2980 Check_Function_Writable_Actuals (N); | 3036 Check_Function_Writable_Actuals (N); |
2981 | |
2982 return; | 3037 return; |
2983 end if; | 3038 end if; |
2984 | 3039 |
2985 if Nkind (R) = N_Range | 3040 if Nkind (R) = N_Range |
2986 or else (Nkind (R) = N_Attribute_Reference | 3041 or else (Nkind (R) = N_Attribute_Reference |
3142 Skip_First : Boolean := False) | 3197 Skip_First : Boolean := False) |
3143 is | 3198 is |
3144 Actuals : constant List_Id := Parameter_Associations (N); | 3199 Actuals : constant List_Id := Parameter_Associations (N); |
3145 Prev_T : constant Entity_Id := Etype (N); | 3200 Prev_T : constant Entity_Id := Etype (N); |
3146 | 3201 |
3202 -- Recognize cases of prefixed calls that have been rewritten in | |
3203 -- various ways. The simplest case is a rewritten selected component, | |
3204 -- but it can also be an already-examined indexed component, or a | |
3205 -- prefix that is itself a rewritten prefixed call that is in turn | |
3206 -- an indexed call (the syntactic ambiguity involving the indexing of | |
3207 -- a function with defaulted parameters that returns an array). | |
3208 -- A flag Maybe_Indexed_Call might be useful here ??? | |
3209 | |
3147 Must_Skip : constant Boolean := Skip_First | 3210 Must_Skip : constant Boolean := Skip_First |
3148 or else Nkind (Original_Node (N)) = N_Selected_Component | 3211 or else Nkind (Original_Node (N)) = N_Selected_Component |
3149 or else | 3212 or else |
3150 (Nkind (Original_Node (N)) = N_Indexed_Component | 3213 (Nkind (Original_Node (N)) = N_Indexed_Component |
3151 and then Nkind (Prefix (Original_Node (N))) | 3214 and then Nkind (Prefix (Original_Node (N))) = |
3152 = N_Selected_Component); | 3215 N_Selected_Component) |
3216 or else | |
3217 (Nkind (Parent (N)) = N_Function_Call | |
3218 and then Is_Array_Type (Etype (Name (N))) | |
3219 and then Etype (Original_Node (N)) = | |
3220 Component_Type (Etype (Name (N))) | |
3221 and then Nkind (Original_Node (Parent (N))) = | |
3222 N_Selected_Component); | |
3223 | |
3153 -- The first formal must be omitted from the match when trying to find | 3224 -- The first formal must be omitted from the match when trying to find |
3154 -- a primitive operation that is a possible interpretation, and also | 3225 -- a primitive operation that is a possible interpretation, and also |
3155 -- after the call has been rewritten, because the corresponding actual | 3226 -- after the call has been rewritten, because the corresponding actual |
3156 -- is already known to be compatible, and because this may be an | 3227 -- is already known to be compatible, and because this may be an |
3157 -- indexing of a call with default parameters. | 3228 -- indexing of a call with default parameters. |
3826 end if; | 3897 end if; |
3827 | 3898 |
3828 Comp := First_Entity (T); | 3899 Comp := First_Entity (T); |
3829 while Present (Comp) loop | 3900 while Present (Comp) loop |
3830 if Chars (Comp) = Chars (Sel) | 3901 if Chars (Comp) = Chars (Sel) |
3831 and then Is_Visible_Component (Comp) | 3902 and then Is_Visible_Component (Comp, Sel) |
3832 then | 3903 then |
3833 | 3904 |
3834 -- AI05-105: if the context is an object renaming with | 3905 -- AI05-105: if the context is an object renaming with |
3835 -- an anonymous access type, the expected type of the | 3906 -- an anonymous access type, the expected type of the |
3836 -- object must be anonymous. This is a name resolution rule. | 3907 -- object must be anonymous. This is a name resolution rule. |
4098 | 4169 |
4099 if Nkind (Discrete_Subtype_Definition (Loop_Par)) = N_Function_Call | 4170 if Nkind (Discrete_Subtype_Definition (Loop_Par)) = N_Function_Call |
4100 and then Parent (Loop_Par) /= N | 4171 and then Parent (Loop_Par) /= N |
4101 then | 4172 then |
4102 -- The parser cannot distinguish between a loop specification | 4173 -- The parser cannot distinguish between a loop specification |
4103 -- and an iterator specification. If after pre-analysis the | 4174 -- and an iterator specification. If after preanalysis the |
4104 -- proper form has been recognized, rewrite the expression to | 4175 -- proper form has been recognized, rewrite the expression to |
4105 -- reflect the right kind. This is needed for proper ASIS | 4176 -- reflect the right kind. This is needed for proper ASIS |
4106 -- navigation. If expansion is enabled, the transformation is | 4177 -- navigation. If expansion is enabled, the transformation is |
4107 -- performed when the expression is rewritten as a loop. | 4178 -- performed when the expression is rewritten as a loop. |
4108 | 4179 |
4231 Get_Next_Interp (I2, It2); | 4302 Get_Next_Interp (I2, It2); |
4232 end loop; | 4303 end loop; |
4233 end if; | 4304 end if; |
4234 end Check_High_Bound; | 4305 end Check_High_Bound; |
4235 | 4306 |
4236 ----------------------------- | 4307 -------------------------------- |
4237 -- Is_Universal_Expression -- | 4308 -- Check_Universal_Expression -- |
4238 ----------------------------- | 4309 -------------------------------- |
4239 | 4310 |
4240 procedure Check_Universal_Expression (N : Node_Id) is | 4311 procedure Check_Universal_Expression (N : Node_Id) is |
4241 begin | 4312 begin |
4242 if Etype (N) = Universal_Integer | 4313 if Etype (N) = Universal_Integer |
4243 and then Nkind (N) /= N_Integer_Literal | 4314 and then Nkind (N) /= N_Integer_Literal |
4986 | 5057 |
4987 Is_Private_Op := True; | 5058 Is_Private_Op := True; |
4988 end if; | 5059 end if; |
4989 end if; | 5060 end if; |
4990 | 5061 |
4991 Next_Entity (Comp); | 5062 -- Do not examine private operations if not within scope of |
5063 -- the synchronized type. | |
5064 | |
4992 exit when not In_Scope | 5065 exit when not In_Scope |
4993 and then | 5066 and then |
4994 Comp = First_Private_Entity (Base_Type (Prefix_Type)); | 5067 Comp = First_Private_Entity (Base_Type (Prefix_Type)); |
5068 Next_Entity (Comp); | |
4995 end loop; | 5069 end loop; |
4996 | 5070 |
4997 -- If the scope is a current instance, the prefix cannot be an | 5071 -- If the scope is a current instance, the prefix cannot be an |
4998 -- expression of the same type, unless the selector designates a | 5072 -- expression of the same type, unless the selector designates a |
4999 -- public operation (otherwise that would represent an attempt to | 5073 -- public operation (otherwise that would represent an attempt to |
5242 -- well fall through and generate a compilation error anyway. | 5316 -- well fall through and generate a compilation error anyway. |
5243 | 5317 |
5244 Comp := First_Component (Base_Type (Prefix_Type)); | 5318 Comp := First_Component (Base_Type (Prefix_Type)); |
5245 while Present (Comp) loop | 5319 while Present (Comp) loop |
5246 if Chars (Comp) = Chars (Sel) | 5320 if Chars (Comp) = Chars (Sel) |
5247 and then Is_Visible_Component (Comp) | 5321 and then Is_Visible_Component (Comp, Sel) |
5248 then | 5322 then |
5249 Set_Entity_With_Checks (Sel, Comp); | 5323 Set_Entity_With_Checks (Sel, Comp); |
5250 Generate_Reference (Comp, Sel); | 5324 Generate_Reference (Comp, Sel); |
5251 Set_Etype (Sel, Etype (Comp)); | 5325 Set_Etype (Sel, Etype (Comp)); |
5252 Set_Etype (N, Etype (Comp)); | 5326 Set_Etype (N, Etype (Comp)); |
5949 return; | 6023 return; |
5950 end if; | 6024 end if; |
5951 | 6025 |
5952 Comp := First_Entity (Prefix); | 6026 Comp := First_Entity (Prefix); |
5953 while Nr_Of_Suggestions <= Max_Suggestions and then Present (Comp) loop | 6027 while Nr_Of_Suggestions <= Max_Suggestions and then Present (Comp) loop |
5954 if Is_Visible_Component (Comp) then | 6028 if Is_Visible_Component (Comp, Sel) then |
5955 if Is_Bad_Spelling_Of (Chars (Comp), Chars (Sel)) then | 6029 if Is_Bad_Spelling_Of (Chars (Comp), Chars (Sel)) then |
5956 Nr_Of_Suggestions := Nr_Of_Suggestions + 1; | 6030 Nr_Of_Suggestions := Nr_Of_Suggestions + 1; |
5957 | 6031 |
5958 case Nr_Of_Suggestions is | 6032 case Nr_Of_Suggestions is |
5959 when 1 => Suggestion_1 := Comp; | 6033 when 1 => Suggestion_1 := Comp; |
8647 Save_Interps (Subprog, Node_To_Replace); | 8721 Save_Interps (Subprog, Node_To_Replace); |
8648 | 8722 |
8649 else | 8723 else |
8650 -- The type of the subprogram may be a limited view obtained | 8724 -- The type of the subprogram may be a limited view obtained |
8651 -- transitively from another unit. If full view is available, | 8725 -- transitively from another unit. If full view is available, |
8652 -- use it to analyze call. | 8726 -- use it to analyze call. If there is no nonlimited view, then |
8727 -- this is diagnosed when analyzing the rewritten call. | |
8653 | 8728 |
8654 declare | 8729 declare |
8655 T : constant Entity_Id := Etype (Subprog); | 8730 T : constant Entity_Id := Etype (Subprog); |
8656 begin | 8731 begin |
8657 if From_Limited_With (T) then | 8732 if From_Limited_With (T) then |
8851 | 8926 |
8852 procedure Traverse_Homonyms | 8927 procedure Traverse_Homonyms |
8853 (Anc_Type : Entity_Id; | 8928 (Anc_Type : Entity_Id; |
8854 Error : out Boolean) | 8929 Error : out Boolean) |
8855 is | 8930 is |
8856 Cls_Type : Entity_Id; | 8931 function First_Formal_Match |
8857 Hom : Entity_Id; | 8932 (Subp_Id : Entity_Id; |
8858 Hom_Ref : Node_Id; | 8933 Typ : Entity_Id) return Boolean; |
8859 Success : Boolean; | 8934 -- Predicate to verify that the first foramal of class-wide |
8935 -- subprogram Subp_Id matches type Typ of the prefix. | |
8936 | |
8937 ------------------------ | |
8938 -- First_Formal_Match -- | |
8939 ------------------------ | |
8940 | |
8941 function First_Formal_Match | |
8942 (Subp_Id : Entity_Id; | |
8943 Typ : Entity_Id) return Boolean | |
8944 is | |
8945 Ctrl : constant Entity_Id := First_Formal (Subp_Id); | |
8946 | |
8947 begin | |
8948 return | |
8949 Present (Ctrl) | |
8950 and then | |
8951 (Base_Type (Etype (Ctrl)) = Typ | |
8952 or else | |
8953 (Ekind (Etype (Ctrl)) = E_Anonymous_Access_Type | |
8954 and then | |
8955 Base_Type (Designated_Type (Etype (Ctrl))) = | |
8956 Typ)); | |
8957 end First_Formal_Match; | |
8958 | |
8959 -- Local variables | |
8960 | |
8961 CW_Typ : constant Entity_Id := Class_Wide_Type (Anc_Type); | |
8962 | |
8963 Candidate : Entity_Id; | |
8964 -- If homonym is a renaming, examine the renamed program | |
8965 | |
8966 Hom : Entity_Id; | |
8967 Hom_Ref : Node_Id; | |
8968 Success : Boolean; | |
8969 | |
8970 -- Start of processing for Traverse_Homonyms | |
8860 | 8971 |
8861 begin | 8972 begin |
8862 Error := False; | 8973 Error := False; |
8863 | |
8864 Cls_Type := Class_Wide_Type (Anc_Type); | |
8865 | |
8866 Hom := Current_Entity (Subprog); | |
8867 | 8974 |
8868 -- Find a non-hidden operation whose first parameter is of the | 8975 -- Find a non-hidden operation whose first parameter is of the |
8869 -- class-wide type, a subtype thereof, or an anonymous access | 8976 -- class-wide type, a subtype thereof, or an anonymous access |
8870 -- to same. If in an instance, the operation can be considered | 8977 -- to same. If in an instance, the operation can be considered |
8871 -- even if hidden (it may be hidden because the instantiation | 8978 -- even if hidden (it may be hidden because the instantiation |
8872 -- is expanded after the containing package has been analyzed). | 8979 -- is expanded after the containing package has been analyzed). |
8873 | 8980 -- If the subprogram is a generic actual in an enclosing instance, |
8981 -- it appears as a renaming that is a candidate interpretation as | |
8982 -- well. | |
8983 | |
8984 Hom := Current_Entity (Subprog); | |
8874 while Present (Hom) loop | 8985 while Present (Hom) loop |
8875 if Ekind_In (Hom, E_Procedure, E_Function) | 8986 if Ekind_In (Hom, E_Procedure, E_Function) |
8876 and then (not Is_Hidden (Hom) or else In_Instance) | 8987 and then Present (Renamed_Entity (Hom)) |
8877 and then Scope (Hom) = Scope (Base_Type (Anc_Type)) | 8988 and then Is_Generic_Actual_Subprogram (Hom) |
8878 and then Present (First_Formal (Hom)) | 8989 and then In_Open_Scopes (Scope (Hom)) |
8879 and then | 8990 then |
8880 (Base_Type (Etype (First_Formal (Hom))) = Cls_Type | 8991 Candidate := Renamed_Entity (Hom); |
8881 or else | 8992 else |
8882 (Is_Access_Type (Etype (First_Formal (Hom))) | 8993 Candidate := Hom; |
8883 and then | 8994 end if; |
8884 Ekind (Etype (First_Formal (Hom))) = | 8995 |
8885 E_Anonymous_Access_Type | 8996 if Ekind_In (Candidate, E_Function, E_Procedure) |
8886 and then | 8997 and then (not Is_Hidden (Candidate) or else In_Instance) |
8887 Base_Type | 8998 and then Scope (Candidate) = Scope (Base_Type (Anc_Type)) |
8888 (Designated_Type (Etype (First_Formal (Hom)))) = | 8999 and then First_Formal_Match (Candidate, CW_Typ) |
8889 Cls_Type)) | |
8890 then | 9000 then |
8891 -- If the context is a procedure call, ignore functions | 9001 -- If the context is a procedure call, ignore functions |
8892 -- in the name of the call. | 9002 -- in the name of the call. |
8893 | 9003 |
8894 if Ekind (Hom) = E_Function | 9004 if Ekind (Candidate) = E_Function |
8895 and then Nkind (Parent (N)) = N_Procedure_Call_Statement | 9005 and then Nkind (Parent (N)) = N_Procedure_Call_Statement |
8896 and then N = Name (Parent (N)) | 9006 and then N = Name (Parent (N)) |
8897 then | 9007 then |
8898 goto Next_Hom; | 9008 goto Next_Hom; |
8899 | 9009 |
8900 -- If the context is a function call, ignore procedures | 9010 -- If the context is a function call, ignore procedures |
8901 -- in the name of the call. | 9011 -- in the name of the call. |
8902 | 9012 |
8903 elsif Ekind (Hom) = E_Procedure | 9013 elsif Ekind (Candidate) = E_Procedure |
8904 and then Nkind (Parent (N)) /= N_Procedure_Call_Statement | 9014 and then Nkind (Parent (N)) /= N_Procedure_Call_Statement |
8905 then | 9015 then |
8906 goto Next_Hom; | 9016 goto Next_Hom; |
8907 end if; | 9017 end if; |
8908 | 9018 |
8909 Set_Etype (Call_Node, Any_Type); | 9019 Set_Etype (Call_Node, Any_Type); |
8910 Set_Is_Overloaded (Call_Node, False); | 9020 Set_Is_Overloaded (Call_Node, False); |
8911 Success := False; | 9021 Success := False; |
8912 | 9022 |
8913 if No (Matching_Op) then | 9023 if No (Matching_Op) then |
8914 Hom_Ref := New_Occurrence_Of (Hom, Sloc (Subprog)); | 9024 Hom_Ref := New_Occurrence_Of (Candidate, Sloc (Subprog)); |
8915 Set_Etype (Call_Node, Any_Type); | 9025 |
9026 Set_Etype (Call_Node, Any_Type); | |
9027 Set_Name (Call_Node, Hom_Ref); | |
8916 Set_Parent (Call_Node, Parent (Node_To_Replace)); | 9028 Set_Parent (Call_Node, Parent (Node_To_Replace)); |
8917 | |
8918 Set_Name (Call_Node, Hom_Ref); | |
8919 | 9029 |
8920 Analyze_One_Call | 9030 Analyze_One_Call |
8921 (N => Call_Node, | 9031 (N => Call_Node, |
8922 Nam => Hom, | 9032 Nam => Candidate, |
8923 Report => Report_Error, | 9033 Report => Report_Error, |
8924 Success => Success, | 9034 Success => Success, |
8925 Skip_First => True); | 9035 Skip_First => True); |
8926 | 9036 |
8927 Matching_Op := | 9037 Matching_Op := |
8928 Valid_Candidate (Success, Call_Node, Hom); | 9038 Valid_Candidate (Success, Call_Node, Candidate); |
8929 | 9039 |
8930 else | 9040 else |
8931 Analyze_One_Call | 9041 Analyze_One_Call |
8932 (N => Call_Node, | 9042 (N => Call_Node, |
8933 Nam => Hom, | 9043 Nam => Candidate, |
8934 Report => Report_Error, | 9044 Report => Report_Error, |
8935 Success => Success, | 9045 Success => Success, |
8936 Skip_First => True); | 9046 Skip_First => True); |
8937 | 9047 |
8938 -- The same operation may be encountered on two homonym | 9048 -- The same operation may be encountered on two homonym |
8939 -- traversals, before and after looking at interfaces. | 9049 -- traversals, before and after looking at interfaces. |
8940 -- Check for this case before reporting a real ambiguity. | 9050 -- Check for this case before reporting a real ambiguity. |
8941 | 9051 |
8942 if Present (Valid_Candidate (Success, Call_Node, Hom)) | 9052 if Present |
9053 (Valid_Candidate (Success, Call_Node, Candidate)) | |
8943 and then Nkind (Call_Node) /= N_Function_Call | 9054 and then Nkind (Call_Node) /= N_Function_Call |
8944 and then Hom /= Matching_Op | 9055 and then Candidate /= Matching_Op |
8945 then | 9056 then |
8946 Error_Msg_NE ("ambiguous call to&", N, Hom); | 9057 Error_Msg_NE ("ambiguous call to&", N, Hom); |
8947 Report_Ambiguity (Matching_Op); | 9058 Report_Ambiguity (Matching_Op); |
8948 Report_Ambiguity (Hom); | 9059 Report_Ambiguity (Hom); |
8949 Error := True; | 9060 Error := True; |
9092 return; | 9203 return; |
9093 end if; | 9204 end if; |
9094 | 9205 |
9095 declare | 9206 declare |
9096 Dup_Call_Node : constant Node_Id := New_Copy (New_Call_Node); | 9207 Dup_Call_Node : constant Node_Id := New_Copy (New_Call_Node); |
9097 CW_Result : Boolean; | 9208 Ignore : Boolean; |
9098 Prim_Result : Boolean; | 9209 Prim_Result : Boolean := False; |
9099 pragma Unreferenced (CW_Result); | |
9100 | 9210 |
9101 begin | 9211 begin |
9102 if not CW_Test_Only then | 9212 if not CW_Test_Only then |
9103 Prim_Result := | 9213 Prim_Result := |
9104 Try_Primitive_Operation | 9214 Try_Primitive_Operation |
9109 -- Check if there is a class-wide subprogram covering the | 9219 -- Check if there is a class-wide subprogram covering the |
9110 -- primitive. This check must be done even if a candidate | 9220 -- primitive. This check must be done even if a candidate |
9111 -- was found in order to report ambiguous calls. | 9221 -- was found in order to report ambiguous calls. |
9112 | 9222 |
9113 if not Prim_Result then | 9223 if not Prim_Result then |
9114 CW_Result := | 9224 Ignore := |
9115 Try_Class_Wide_Operation | 9225 Try_Class_Wide_Operation |
9116 (Call_Node => New_Call_Node, | 9226 (Call_Node => New_Call_Node, |
9117 Node_To_Replace => Node_To_Replace); | 9227 Node_To_Replace => Node_To_Replace); |
9118 | 9228 |
9119 -- If we found a primitive we search for class-wide subprograms | 9229 -- If we found a primitive we search for class-wide subprograms |
9120 -- using a duplicate of the call node (done to avoid missing its | 9230 -- using a duplicate of the call node (done to avoid missing its |
9121 -- decoration if there is no ambiguity). | 9231 -- decoration if there is no ambiguity). |
9122 | 9232 |
9123 else | 9233 else |
9124 CW_Result := | 9234 Ignore := |
9125 Try_Class_Wide_Operation | 9235 Try_Class_Wide_Operation |
9126 (Call_Node => Dup_Call_Node, | 9236 (Call_Node => Dup_Call_Node, |
9127 Node_To_Replace => Node_To_Replace); | 9237 Node_To_Replace => Node_To_Replace); |
9128 end if; | 9238 end if; |
9129 end; | 9239 end; |
9351 --------------------------- | 9461 --------------------------- |
9352 -- Is_Private_Overriding -- | 9462 -- Is_Private_Overriding -- |
9353 --------------------------- | 9463 --------------------------- |
9354 | 9464 |
9355 function Is_Private_Overriding (Op : Entity_Id) return Boolean is | 9465 function Is_Private_Overriding (Op : Entity_Id) return Boolean is |
9356 Visible_Op : constant Entity_Id := Homonym (Op); | 9466 Visible_Op : Entity_Id; |
9357 | 9467 |
9358 begin | 9468 begin |
9359 return Present (Visible_Op) | 9469 -- The subprogram may be overloaded with both visible and private |
9360 and then Scope (Op) = Scope (Visible_Op) | 9470 -- entities with the same name. We have to scan the chain of |
9361 and then not Comes_From_Source (Visible_Op) | 9471 -- homonyms to determine whether there is a previous implicit |
9362 and then Alias (Visible_Op) = Op | 9472 -- declaration in the same scope that is overridden by the |
9363 and then not Is_Hidden (Visible_Op); | 9473 -- private candidate. |
9474 | |
9475 Visible_Op := Homonym (Op); | |
9476 while Present (Visible_Op) loop | |
9477 if Scope (Op) /= Scope (Visible_Op) then | |
9478 return False; | |
9479 | |
9480 elsif not Comes_From_Source (Visible_Op) | |
9481 and then Alias (Visible_Op) = Op | |
9482 and then not Is_Hidden (Visible_Op) | |
9483 then | |
9484 return True; | |
9485 end if; | |
9486 | |
9487 Visible_Op := Homonym (Visible_Op); | |
9488 end loop; | |
9489 | |
9490 return False; | |
9364 end Is_Private_Overriding; | 9491 end Is_Private_Overriding; |
9365 | 9492 |
9366 ----------------- | 9493 ----------------- |
9367 -- Names_Match -- | 9494 -- Names_Match -- |
9368 ----------------- | 9495 ----------------- |
9385 elsif Is_Protected_Type (Obj_Type) then | 9512 elsif Is_Protected_Type (Obj_Type) then |
9386 return | 9513 return |
9387 Present (Original_Protected_Subprogram (Prim_Op)) | 9514 Present (Original_Protected_Subprogram (Prim_Op)) |
9388 and then Chars (Original_Protected_Subprogram (Prim_Op)) = | 9515 and then Chars (Original_Protected_Subprogram (Prim_Op)) = |
9389 Chars (Subprog); | 9516 Chars (Subprog); |
9517 | |
9518 -- In an instance, the selector name may be a generic actual that | |
9519 -- renames a primitive operation of the type of the prefix. | |
9520 | |
9521 elsif In_Instance and then Present (Current_Entity (Subprog)) then | |
9522 declare | |
9523 Subp : constant Entity_Id := Current_Entity (Subprog); | |
9524 begin | |
9525 if Present (Subp) | |
9526 and then Is_Subprogram (Subp) | |
9527 and then Present (Renamed_Entity (Subp)) | |
9528 and then Is_Generic_Actual_Subprogram (Subp) | |
9529 and then Chars (Renamed_Entity (Subp)) = Chars (Prim_Op) | |
9530 then | |
9531 return True; | |
9532 end if; | |
9533 end; | |
9390 end if; | 9534 end if; |
9391 | 9535 |
9392 return False; | 9536 return False; |
9393 end Names_Match; | 9537 end Names_Match; |
9394 | 9538 |