Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/exp_util.ads @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
4 -- -- | 4 -- -- |
5 -- E X P _ U T I L -- | 5 -- E X P _ U T I L -- |
6 -- -- | 6 -- -- |
7 -- S p e c -- | 7 -- S p e c -- |
8 -- -- | 8 -- -- |
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. -- | 9 -- Copyright (C) 1992-2019, 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- -- |
87 -- Note if more than one insert call is made specifying the same | 87 -- Note if more than one insert call is made specifying the same |
88 -- Assoc_Node, then the actions are elaborated in the order of the | 88 -- Assoc_Node, then the actions are elaborated in the order of the |
89 -- calls, and this guarantee is preserved for the special cases above. | 89 -- calls, and this guarantee is preserved for the special cases above. |
90 | 90 |
91 procedure Insert_Action | 91 procedure Insert_Action |
92 (Assoc_Node : Node_Id; | 92 (Assoc_Node : Node_Id; |
93 Ins_Action : Node_Id); | 93 Ins_Action : Node_Id; |
94 Spec_Expr_OK : Boolean := False); | |
94 -- Insert the action Ins_Action at the appropriate point as described | 95 -- Insert the action Ins_Action at the appropriate point as described |
95 -- above. The action is analyzed using the default checks after it is | 96 -- above. The action is analyzed using the default checks after it is |
96 -- inserted. Assoc_Node is the node with which the action is associated. | 97 -- inserted. Assoc_Node is the node with which the action is associated. |
98 -- When flag Spec_Expr_OK is set, insertions triggered in the context of | |
99 -- spec expressions are honored, even though they contradict "Handling | |
100 -- of Default and Per-Object Expressions". | |
97 | 101 |
98 procedure Insert_Action | 102 procedure Insert_Action |
99 (Assoc_Node : Node_Id; | 103 (Assoc_Node : Node_Id; |
100 Ins_Action : Node_Id; | 104 Ins_Action : Node_Id; |
101 Suppress : Check_Id); | 105 Suppress : Check_Id; |
106 Spec_Expr_OK : Boolean := False); | |
102 -- Insert the action Ins_Action at the appropriate point as described | 107 -- Insert the action Ins_Action at the appropriate point as described |
103 -- above. The action is analyzed using the default checks as modified | 108 -- above. The action is analyzed using the default checks as modified |
104 -- by the given Suppress argument after it is inserted. Assoc_Node is | 109 -- by the given Suppress argument after it is inserted. Assoc_Node is |
105 -- the node with which the action is associated. | 110 -- the node with which the action is associated. When flag Spec_Expr_OK |
111 -- is set, insertions triggered in the context of spec expressions are | |
112 -- honored, even though they contradict "Handling of Default and Per- | |
113 -- Object Expressions". | |
106 | 114 |
107 procedure Insert_Actions | 115 procedure Insert_Actions |
108 (Assoc_Node : Node_Id; | 116 (Assoc_Node : Node_Id; |
109 Ins_Actions : List_Id); | 117 Ins_Actions : List_Id; |
118 Spec_Expr_OK : Boolean := False); | |
110 -- Insert the list of action Ins_Actions at the appropriate point as | 119 -- Insert the list of action Ins_Actions at the appropriate point as |
111 -- described above. The actions are analyzed using the default checks | 120 -- described above. The actions are analyzed using the default checks |
112 -- after they are inserted. Assoc_Node is the node with which the actions | 121 -- after they are inserted. Assoc_Node is the node with which the actions |
113 -- are associated. Ins_Actions may be No_List, in which case the call has | 122 -- are associated. Ins_Actions may be No_List, in which case the call has |
114 -- no effect. | 123 -- no effect. When flag Spec_Expr_OK is set, insertions triggered in the |
124 -- context of spec expressions are honored, even though they contradict | |
125 -- "Handling of Default and Per-Object Expressions". | |
115 | 126 |
116 procedure Insert_Actions | 127 procedure Insert_Actions |
117 (Assoc_Node : Node_Id; | 128 (Assoc_Node : Node_Id; |
118 Ins_Actions : List_Id; | 129 Ins_Actions : List_Id; |
119 Suppress : Check_Id); | 130 Suppress : Check_Id; |
131 Spec_Expr_OK : Boolean := False); | |
120 -- Insert the list of action Ins_Actions at the appropriate point as | 132 -- Insert the list of action Ins_Actions at the appropriate point as |
121 -- described above. The actions are analyzed using the default checks | 133 -- described above. The actions are analyzed using the default checks |
122 -- as modified by the given Suppress argument after they are inserted. | 134 -- as modified by the given Suppress argument after they are inserted. |
123 -- Assoc_Node is the node with which the actions are associated. | 135 -- Assoc_Node is the node with which the actions are associated. List |
124 -- Ins_Actions may be No_List, in which case the call has no effect. | 136 -- Ins_Actions may be No_List, in which case the call has no effect. |
137 -- When flag Spec_Expr_OK is set, insertions triggered in the context of | |
138 -- spec expressions are honored, even though they contradict "Handling | |
139 -- of Default and Per-Object Expressions". | |
125 | 140 |
126 procedure Insert_Action_After | 141 procedure Insert_Action_After |
127 (Assoc_Node : Node_Id; | 142 (Assoc_Node : Node_Id; |
128 Ins_Action : Node_Id); | 143 Ins_Action : Node_Id); |
129 -- Assoc_Node must be a node in a list. Same as Insert_Action but the | 144 -- Assoc_Node must be a node in a list. Same as Insert_Action but the |
222 -- the given type. The freeze actions are attached to the freeze node for | 237 -- the given type. The freeze actions are attached to the freeze node for |
223 -- the type. Actions will be elaborated in the order in which they are | 238 -- the type. Actions will be elaborated in the order in which they are |
224 -- added, and the actions within the list will be elaborated in list order. | 239 -- added, and the actions within the list will be elaborated in list order. |
225 -- Note that the added nodes are not analyzed. The analyze call is found in | 240 -- Note that the added nodes are not analyzed. The analyze call is found in |
226 -- Exp_Ch13.Expand_N_Freeze_Entity. | 241 -- Exp_Ch13.Expand_N_Freeze_Entity. |
242 | |
243 function Attribute_Constrained_Static_Value (Pref : Node_Id) return Boolean; | |
244 -- Return the static value of a statically known attribute reference | |
245 -- Pref'Constrained. | |
227 | 246 |
228 procedure Build_Allocate_Deallocate_Proc | 247 procedure Build_Allocate_Deallocate_Proc |
229 (N : Node_Id; | 248 (N : Node_Id; |
230 Is_Allocate : Boolean); | 249 Is_Allocate : Boolean); |
231 -- Create a custom Allocate/Deallocate to be associated with an allocation | 250 -- Create a custom Allocate/Deallocate to be associated with an allocation |
384 -- mode. Note that we don't need to worry about unary operator cases, | 403 -- mode. Note that we don't need to worry about unary operator cases, |
385 -- since for floating-point, abs, unary "-", and unary "+" can never | 404 -- since for floating-point, abs, unary "-", and unary "+" can never |
386 -- case overflow. | 405 -- case overflow. |
387 | 406 |
388 function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean; | 407 function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean; |
389 -- This function is in charge of detecting record components that may | 408 -- This function is in charge of detecting record components that may cause |
390 -- cause trouble in the back end if an attempt is made to assign the | 409 -- trouble for the back end if an attempt is made to access the component |
391 -- component. The back end can handle such assignments with no problem if | 410 -- as a whole. The back end can handle such accesses with no problem if the |
392 -- the components involved are small (64-bits or less) records or scalar | 411 -- components involved are small (64 bits or less) records or scalar items |
393 -- items (including bit-packed arrays represented with modular types) or | 412 -- (including bit-packed arrays represented with a modular type), or else |
394 -- are both aligned on a byte boundary (starting on a byte boundary, and | 413 -- if they are aligned on byte boundaries (i.e. starting on a byte boundary |
395 -- occupying an integral number of bytes). | 414 -- and occupying an integral number of bytes). |
396 -- | 415 -- |
397 -- However, problems arise for records larger than 64 bits, or for arrays | 416 -- However, problems arise for records larger than 64 bits, or for arrays |
398 -- (other than bit-packed arrays represented with a modular type) if the | 417 -- (other than bit-packed arrays represented with a modular type) if the |
399 -- component starts on a non-byte boundary, or does not occupy an integral | 418 -- component either does not start on a byte boundary or does not occupy an |
400 -- number of bytes (i.e. there are some bits possibly shared with fields | 419 -- integral number of bytes (i.e. there are some bits possibly shared with |
401 -- at the start or beginning of the component). The back end cannot handle | 420 -- other components at the start or the end of the component). The back end |
402 -- loading and storing such components in a single operation. | 421 -- cannot handle loading from or storing to such components as a whole. |
403 -- | 422 -- |
404 -- This function is used to detect the troublesome situation. it is | 423 -- This function is used to detect the troublesome situation. It is meant |
405 -- conservative in the sense that it produces True unless it knows for | 424 -- to be conservative in the sense that it produces True unless it knows |
406 -- sure that the component is safe (as outlined in the first paragraph | 425 -- for sure that the component is safe (as outlined in the first paragraph |
407 -- above). The code generation for record and array assignment checks for | 426 -- above). The processing for record and array assignment indirectly checks |
408 -- trouble using this function, and if so the assignment is generated | 427 -- for trouble using this function and, if so, the assignment is expanded |
409 -- component-wise, which the back end is required to handle correctly. | 428 -- component-wise, which the back end is required to handle correctly. |
410 -- | |
411 -- Note that in GNAT 3, the back end will reject such components anyway, | |
412 -- so the hard work in checking for this case is wasted in GNAT 3, but | |
413 -- it is harmless, so it is easier to do it in all cases, rather than | |
414 -- conditionalize it in GNAT 5 or beyond. | |
415 | 429 |
416 function Containing_Package_With_Ext_Axioms | 430 function Containing_Package_With_Ext_Axioms |
417 (E : Entity_Id) return Entity_Id; | 431 (E : Entity_Id) return Entity_Id; |
418 -- Returns the package entity with an external axiomatization containing E, | 432 -- Returns the package entity with an external axiomatization containing E, |
419 -- if any, or Empty if none. | 433 -- if any, or Empty if none. |
542 -- then simply returns Cond1 (this allows the use of Empty to initialize a | 556 -- then simply returns Cond1 (this allows the use of Empty to initialize a |
543 -- series of checks evolved by this routine, with a final result of Empty | 557 -- series of checks evolved by this routine, with a final result of Empty |
544 -- indicating that no checks were required). The Sloc field of the | 558 -- indicating that no checks were required). The Sloc field of the |
545 -- constructed N_Or_Else node is copied from Cond1. | 559 -- constructed N_Or_Else node is copied from Cond1. |
546 | 560 |
547 function Exceptions_In_Finalization_OK return Boolean; | |
548 -- Determine whether the finalization machinery can safely add exception | |
549 -- handlers and recovery circuitry. | |
550 | |
551 procedure Expand_Static_Predicates_In_Choices (N : Node_Id); | 561 procedure Expand_Static_Predicates_In_Choices (N : Node_Id); |
552 -- N is either a case alternative or a variant. The Discrete_Choices field | 562 -- N is either a case alternative or a variant. The Discrete_Choices field |
553 -- of N points to a list of choices. If any of these choices is the name | 563 -- of N points to a list of choices. If any of these choices is the name |
554 -- of a (statically) predicated subtype, then it is rewritten as the series | 564 -- of a (statically) predicated subtype, then it is rewritten as the series |
555 -- of choices that correspond to the values allowed for the subtype. | 565 -- of choices that correspond to the values allowed for the subtype. |
586 (T : Entity_Id; | 596 (T : Entity_Id; |
587 Iface : Entity_Id) return Entity_Id; | 597 Iface : Entity_Id) return Entity_Id; |
588 -- Ada 2005 (AI-251): Given a type T and an interface Iface, return the | 598 -- Ada 2005 (AI-251): Given a type T and an interface Iface, return the |
589 -- record component containing the tag of Iface if T implements Iface or | 599 -- record component containing the tag of Iface if T implements Iface or |
590 -- Empty if it does not. | 600 -- Empty if it does not. |
601 | |
602 -- WARNING: There is a matching C declaration of this subprogram in fe.h | |
591 | 603 |
592 function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id; | 604 function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id; |
593 -- Find the first primitive operation of a tagged type T with name Name. | 605 -- Find the first primitive operation of a tagged type T with name Name. |
594 -- This function allows the use of a primitive operation which is not | 606 -- This function allows the use of a primitive operation which is not |
595 -- directly visible. If T is a class wide type, then the reference is to an | 607 -- directly visible. If T is a class wide type, then the reference is to an |
722 (E : Entity_Id) return Boolean; | 734 (E : Entity_Id) return Boolean; |
723 -- Returns whether E is a package entity, for which the initial list of | 735 -- Returns whether E is a package entity, for which the initial list of |
724 -- pragmas at the start of the package declaration contains | 736 -- pragmas at the start of the package declaration contains |
725 -- pragma Annotate (GNATprove, External_Axiomatization); | 737 -- pragma Annotate (GNATprove, External_Axiomatization); |
726 | 738 |
727 function Homonym_Number (Subp : Entity_Id) return Nat; | 739 function Homonym_Number (Subp : Entity_Id) return Pos; |
728 -- Here subp is the entity for a subprogram. This routine returns the | 740 -- Here subp is the entity for a subprogram. This routine returns the |
729 -- homonym number used to disambiguate overloaded subprograms in the same | 741 -- homonym number used to disambiguate overloaded subprograms in the same |
730 -- scope (the number is used as part of constructed names to make sure that | 742 -- scope (the number is used as part of constructed names to make sure that |
731 -- they are unique). The number is the ordinal position on the Homonym | 743 -- they are unique). The number is the ordinal position on the Homonym |
732 -- chain, counting only entries in the current scope. If an entity is not | 744 -- chain, counting only entries in the current scope. If an entity is not |
771 -- of all the components, including recursively components in all parent | 783 -- of all the components, including recursively components in all parent |
772 -- types. We exclude discriminated types for convenience, it is extremely | 784 -- types. We exclude discriminated types for convenience, it is extremely |
773 -- unlikely that the special processing associated with the use of this | 785 -- unlikely that the special processing associated with the use of this |
774 -- routine is useful for the case of a discriminated type, and testing for | 786 -- routine is useful for the case of a discriminated type, and testing for |
775 -- component overlap would be a pain. | 787 -- component overlap would be a pain. |
788 | |
789 -- WARNING: There is a matching C declaration of this subprogram in fe.h | |
776 | 790 |
777 function Is_Library_Level_Tagged_Type (Typ : Entity_Id) return Boolean; | 791 function Is_Library_Level_Tagged_Type (Typ : Entity_Id) return Boolean; |
778 -- Return True if Typ is a library level tagged type. Currently we use | 792 -- Return True if Typ is a library level tagged type. Currently we use |
779 -- this information to build statically allocated dispatch tables. | 793 -- this information to build statically allocated dispatch tables. |
780 | 794 |
930 (Decl : Node_Id; | 944 (Decl : Node_Id; |
931 Typ : Entity_Id) return Boolean; | 945 Typ : Entity_Id) return Boolean; |
932 -- Check whether the expression in an address clause is restricted to | 946 -- Check whether the expression in an address clause is restricted to |
933 -- consist of constants, when the object has a nontrivial initialization | 947 -- consist of constants, when the object has a nontrivial initialization |
934 -- or is controlled. | 948 -- or is controlled. |
935 | |
936 function Needs_Finalization (Typ : Entity_Id) return Boolean; | |
937 -- Determine whether type Typ is controlled and this requires finalization | |
938 -- actions. | |
939 | 949 |
940 function Non_Limited_Designated_Type (T : Entity_Id) return Entity_Id; | 950 function Non_Limited_Designated_Type (T : Entity_Id) return Entity_Id; |
941 -- An anonymous access type may designate a limited view. Check whether | 951 -- An anonymous access type may designate a limited view. Check whether |
942 -- non-limited view is available during expansion, to examine components | 952 -- non-limited view is available during expansion, to examine components |
943 -- or other characteristics of the full type. | 953 -- or other characteristics of the full type. |
953 -- also inhibit replacement of Volatile or aliased objects since their | 963 -- also inhibit replacement of Volatile or aliased objects since their |
954 -- address might be captured in a way we do not detect. A value of True is | 964 -- address might be captured in a way we do not detect. A value of True is |
955 -- returned only if the replacement is safe. | 965 -- returned only if the replacement is safe. |
956 | 966 |
957 function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean; | 967 function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean; |
958 -- This function is used during processing the assignment of a record or | 968 -- This function is used during processing the assignment of a record or an |
959 -- indexed component. The argument N is either the left hand or right hand | 969 -- array, or the construction of an aggregate. The argument N is either the |
960 -- side of an assignment, and this function determines if there is a record | 970 -- left or the right hand side of an assignment and the function determines |
961 -- component reference where the record may be bit aligned in a manner that | 971 -- whether there is a record component reference where the component may be |
962 -- causes trouble for the back end (see Component_May_Be_Bit_Aligned for | 972 -- bit aligned in a manner that causes trouble for the back end (see also |
963 -- further details). | 973 -- Component_May_Be_Bit_Aligned for further details). |
964 | 974 |
965 function Power_Of_Two (N : Node_Id) return Nat; | 975 function Power_Of_Two (N : Node_Id) return Nat; |
966 -- Determines if N is a known at compile time value which is of the form | 976 -- Determines if N is a known at compile time value which is of the form |
967 -- 2**K, where K is in the range 1 .. M, where the Esize of N is 2**(M+1). | 977 -- 2**K, where K is in the range 1 .. M, where the Esize of N is 2**(M+1). |
968 -- If so, returns the value K, otherwise returns zero. The caller checks | 978 -- If so, returns the value K, otherwise returns zero. The caller checks |
1138 -- N is the node for a boolean array NOT operation, and T is the type of | 1148 -- N is the node for a boolean array NOT operation, and T is the type of |
1139 -- the array. This routine deals with the silly case where the subtype of | 1149 -- the array. This routine deals with the silly case where the subtype of |
1140 -- the boolean array is False..False or True..True, where it is required | 1150 -- the boolean array is False..False or True..True, where it is required |
1141 -- that a Constraint_Error exception be raised (RM 4.5.6(6)). | 1151 -- that a Constraint_Error exception be raised (RM 4.5.6(6)). |
1142 | 1152 |
1143 procedure Silly_Boolean_Array_Xor_Test (N : Node_Id; T : Entity_Id); | 1153 procedure Silly_Boolean_Array_Xor_Test |
1144 -- N is the node for a boolean array XOR operation, and T is the type of | 1154 (N : Node_Id; |
1145 -- the array. This routine deals with the silly case where the subtype of | 1155 R : Node_Id; |
1146 -- the boolean array is True..True, where a raise of a Constraint_Error | 1156 T : Entity_Id); |
1147 -- exception is required (RM 4.5.6(6)). | 1157 -- N is the node for a boolean array XOR operation, T is the type of the |
1158 -- array, and R is a copy of the right operand of N, required to prevent | |
1159 -- scope anomalies when unnesting is in effect. This routine deals with | |
1160 -- the admitedly silly case where the subtype of the boolean array is | |
1161 -- True..True, where a raise of a Constraint_Error exception is required | |
1162 -- (RM 4.5.6(6)) and ACATS-tested. | |
1148 | 1163 |
1149 function Target_Has_Fixed_Ops | 1164 function Target_Has_Fixed_Ops |
1150 (Left_Typ : Entity_Id; | 1165 (Left_Typ : Entity_Id; |
1151 Right_Typ : Entity_Id; | 1166 Right_Typ : Entity_Id; |
1152 Result_Typ : Entity_Id) return Boolean; | 1167 Result_Typ : Entity_Id) return Boolean; |
1156 -- determine whether to expand such operations. | 1171 -- determine whether to expand such operations. |
1157 | 1172 |
1158 function Type_May_Have_Bit_Aligned_Components | 1173 function Type_May_Have_Bit_Aligned_Components |
1159 (Typ : Entity_Id) return Boolean; | 1174 (Typ : Entity_Id) return Boolean; |
1160 -- Determines if Typ is a composite type that has within it (looking down | 1175 -- Determines if Typ is a composite type that has within it (looking down |
1161 -- recursively at any subcomponents), a record type which has component | 1176 -- recursively at subcomponents) a record which contains a component that |
1162 -- that may be bit aligned (see Possible_Bit_Aligned_Component). The result | 1177 -- may be bit aligned in a manner that causes trouble for the back end |
1178 -- (see also Component_May_Be_Bit_Aligned for further details). The result | |
1163 -- is conservative, in that a result of False is decisive. A result of True | 1179 -- is conservative, in that a result of False is decisive. A result of True |
1164 -- means that such a component may or may not be present. | 1180 -- means that such a component may or may not be present. |
1165 | 1181 |
1166 procedure Update_Primitives_Mapping | 1182 procedure Update_Primitives_Mapping |
1167 (Inher_Id : Entity_Id; | 1183 (Inher_Id : Entity_Id; |