Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/exp_attr.adb @ 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 _ A T T R -- | 5 -- E X P _ A T T R -- |
6 -- -- | 6 -- -- |
7 -- B o d y -- | 7 -- B o d y -- |
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- -- |
37 with Exp_Imgv; use Exp_Imgv; | 37 with Exp_Imgv; use Exp_Imgv; |
38 with Exp_Pakd; use Exp_Pakd; | 38 with Exp_Pakd; use Exp_Pakd; |
39 with Exp_Strm; use Exp_Strm; | 39 with Exp_Strm; use Exp_Strm; |
40 with Exp_Tss; use Exp_Tss; | 40 with Exp_Tss; use Exp_Tss; |
41 with Exp_Util; use Exp_Util; | 41 with Exp_Util; use Exp_Util; |
42 with Expander; use Expander; | |
42 with Freeze; use Freeze; | 43 with Freeze; use Freeze; |
43 with Gnatvsn; use Gnatvsn; | 44 with Gnatvsn; use Gnatvsn; |
44 with Itypes; use Itypes; | 45 with Itypes; use Itypes; |
45 with Lib; use Lib; | 46 with Lib; use Lib; |
46 with Namet; use Namet; | 47 with Namet; use Namet; |
637 -- Assume that none of the components and variants are eligible for | 638 -- Assume that none of the components and variants are eligible for |
638 -- verification. | 639 -- verification. |
639 | 640 |
640 Stmts := No_List; | 641 Stmts := No_List; |
641 | 642 |
642 -- Validate componants | 643 -- Validate components |
643 | 644 |
644 Validate_Component_List | 645 Validate_Component_List |
645 (Obj_Id => Obj_Id, | 646 (Obj_Id => Obj_Id, |
646 Comp_List => Component_List (Var), | 647 Comp_List => Component_List (Var), |
647 Stmts => Stmts); | 648 Stmts => Stmts); |
1382 Func_Decl : Node_Id; | 1383 Func_Decl : Node_Id; |
1383 Func_Id : Entity_Id; | 1384 Func_Id : Entity_Id; |
1384 Stmts : List_Id; | 1385 Stmts : List_Id; |
1385 | 1386 |
1386 begin | 1387 begin |
1388 Func_Id := Make_Temporary (Loc, 'F'); | |
1389 | |
1387 -- Wrap the condition of the while loop in a Boolean function. | 1390 -- Wrap the condition of the while loop in a Boolean function. |
1388 -- This avoids the duplication of the same code which may lead | 1391 -- This avoids the duplication of the same code which may lead |
1389 -- to gigi issues with respect to multiple declaration of the | 1392 -- to gigi issues with respect to multiple declaration of the |
1390 -- same entity in the presence of side effects or checks. Note | 1393 -- same entity in the presence of side effects or checks. Note |
1391 -- that the condition actions must also be relocated to the | 1394 -- that the condition actions must also be relocated into the |
1392 -- wrapping function. | 1395 -- wrapping function because they may contain itypes, e.g. in |
1396 -- the case of a comparison involving slices. | |
1393 | 1397 |
1394 -- Generate: | 1398 -- Generate: |
1395 -- <condition actions> | 1399 -- <condition actions> |
1396 -- return <condition>; | 1400 -- return <condition>; |
1397 | 1401 |
1401 Stmts := New_List; | 1405 Stmts := New_List; |
1402 end if; | 1406 end if; |
1403 | 1407 |
1404 Append_To (Stmts, | 1408 Append_To (Stmts, |
1405 Make_Simple_Return_Statement (Loc, | 1409 Make_Simple_Return_Statement (Loc, |
1406 Expression => Relocate_Node (Condition (Scheme)))); | 1410 Expression => |
1411 New_Copy_Tree (Condition (Scheme), | |
1412 New_Scope => Func_Id))); | |
1407 | 1413 |
1408 -- Generate: | 1414 -- Generate: |
1409 -- function Fnn return Boolean is | 1415 -- function Fnn return Boolean is |
1410 -- begin | 1416 -- begin |
1411 -- <Stmts> | 1417 -- <Stmts> |
1412 -- end Fnn; | 1418 -- end Fnn; |
1413 | 1419 |
1414 Func_Id := Make_Temporary (Loc, 'F'); | |
1415 Func_Decl := | 1420 Func_Decl := |
1416 Make_Subprogram_Body (Loc, | 1421 Make_Subprogram_Body (Loc, |
1417 Specification => | 1422 Specification => |
1418 Make_Function_Specification (Loc, | 1423 Make_Function_Specification (Loc, |
1419 Defining_Unit_Name => Func_Id, | 1424 Defining_Unit_Name => Func_Id, |
1428 -- to analyze it in the context of the loop's enclosing scope. | 1433 -- to analyze it in the context of the loop's enclosing scope. |
1429 | 1434 |
1430 Push_Scope (Scope (Loop_Id)); | 1435 Push_Scope (Scope (Loop_Id)); |
1431 Insert_Action (Loop_Stmt, Func_Decl); | 1436 Insert_Action (Loop_Stmt, Func_Decl); |
1432 Pop_Scope; | 1437 Pop_Scope; |
1438 | |
1439 -- The analysis of the condition may have generated itypes | |
1440 -- that are now used within the function: Adjust their | |
1441 -- scopes accordingly so that their use appears in their | |
1442 -- scope of definition. | |
1443 | |
1444 declare | |
1445 Ityp : Entity_Id; | |
1446 | |
1447 begin | |
1448 Ityp := First_Entity (Loop_Id); | |
1449 | |
1450 while Present (Ityp) loop | |
1451 if Is_Itype (Ityp) then | |
1452 Set_Scope (Ityp, Func_Id); | |
1453 end if; | |
1454 Next_Entity (Ityp); | |
1455 end loop; | |
1456 end; | |
1433 | 1457 |
1434 -- Transform the original while loop into an infinite loop | 1458 -- Transform the original while loop into an infinite loop |
1435 -- where the last statement checks the negated condition. This | 1459 -- where the last statement checks the negated condition. This |
1436 -- placement ensures that the condition will not be evaluated | 1460 -- placement ensures that the condition will not be evaluated |
1437 -- twice on the first iteration. | 1461 -- twice on the first iteration. |
1691 -- back end should not count on this). The one bit of special processing | 1715 -- back end should not count on this). The one bit of special processing |
1692 -- required in the normal case is that these two attributes typically | 1716 -- required in the normal case is that these two attributes typically |
1693 -- generate conditionals in the code, so check the relevant restriction. | 1717 -- generate conditionals in the code, so check the relevant restriction. |
1694 | 1718 |
1695 Check_Restriction (No_Implicit_Conditionals, N); | 1719 Check_Restriction (No_Implicit_Conditionals, N); |
1696 | |
1697 -- In Modify_Tree_For_C mode, we rewrite as an if expression | |
1698 | |
1699 if Modify_Tree_For_C then | |
1700 declare | |
1701 Loc : constant Source_Ptr := Sloc (N); | |
1702 Typ : constant Entity_Id := Etype (N); | |
1703 Expr : constant Node_Id := First (Expressions (N)); | |
1704 Left : constant Node_Id := Relocate_Node (Expr); | |
1705 Right : constant Node_Id := Relocate_Node (Next (Expr)); | |
1706 | |
1707 function Make_Compare (Left, Right : Node_Id) return Node_Id; | |
1708 -- Returns Left >= Right for Max, Left <= Right for Min | |
1709 | |
1710 ------------------ | |
1711 -- Make_Compare -- | |
1712 ------------------ | |
1713 | |
1714 function Make_Compare (Left, Right : Node_Id) return Node_Id is | |
1715 begin | |
1716 if Attribute_Name (N) = Name_Max then | |
1717 return | |
1718 Make_Op_Ge (Loc, | |
1719 Left_Opnd => Left, | |
1720 Right_Opnd => Right); | |
1721 else | |
1722 return | |
1723 Make_Op_Le (Loc, | |
1724 Left_Opnd => Left, | |
1725 Right_Opnd => Right); | |
1726 end if; | |
1727 end Make_Compare; | |
1728 | |
1729 -- Start of processing for Min_Max | |
1730 | |
1731 begin | |
1732 -- If both Left and Right are side effect free, then we can just | |
1733 -- use Duplicate_Expr to duplicate the references and return | |
1734 | |
1735 -- (if Left >=|<= Right then Left else Right) | |
1736 | |
1737 if Side_Effect_Free (Left) and then Side_Effect_Free (Right) then | |
1738 Rewrite (N, | |
1739 Make_If_Expression (Loc, | |
1740 Expressions => New_List ( | |
1741 Make_Compare (Left, Right), | |
1742 Duplicate_Subexpr_No_Checks (Left), | |
1743 Duplicate_Subexpr_No_Checks (Right)))); | |
1744 | |
1745 -- Otherwise we generate declarations to capture the values. | |
1746 | |
1747 -- The translation is | |
1748 | |
1749 -- do | |
1750 -- T1 : constant typ := Left; | |
1751 -- T2 : constant typ := Right; | |
1752 -- in | |
1753 -- (if T1 >=|<= T2 then T1 else T2) | |
1754 -- end; | |
1755 | |
1756 else | |
1757 declare | |
1758 T1 : constant Entity_Id := Make_Temporary (Loc, 'T', Left); | |
1759 T2 : constant Entity_Id := Make_Temporary (Loc, 'T', Right); | |
1760 | |
1761 begin | |
1762 Rewrite (N, | |
1763 Make_Expression_With_Actions (Loc, | |
1764 Actions => New_List ( | |
1765 Make_Object_Declaration (Loc, | |
1766 Defining_Identifier => T1, | |
1767 Constant_Present => True, | |
1768 Object_Definition => | |
1769 New_Occurrence_Of (Etype (Left), Loc), | |
1770 Expression => Relocate_Node (Left)), | |
1771 | |
1772 Make_Object_Declaration (Loc, | |
1773 Defining_Identifier => T2, | |
1774 Constant_Present => True, | |
1775 Object_Definition => | |
1776 New_Occurrence_Of (Etype (Right), Loc), | |
1777 Expression => Relocate_Node (Right))), | |
1778 | |
1779 Expression => | |
1780 Make_If_Expression (Loc, | |
1781 Expressions => New_List ( | |
1782 Make_Compare | |
1783 (New_Occurrence_Of (T1, Loc), | |
1784 New_Occurrence_Of (T2, Loc)), | |
1785 New_Occurrence_Of (T1, Loc), | |
1786 New_Occurrence_Of (T2, Loc))))); | |
1787 end; | |
1788 end if; | |
1789 | |
1790 Analyze_And_Resolve (N, Typ); | |
1791 end; | |
1792 end if; | |
1793 end Expand_Min_Max_Attribute; | 1720 end Expand_Min_Max_Attribute; |
1794 | 1721 |
1795 ---------------------------------- | 1722 ---------------------------------- |
1796 -- Expand_N_Attribute_Reference -- | 1723 -- Expand_N_Attribute_Reference -- |
1797 ---------------------------------- | 1724 ---------------------------------- |
2387 ------------- | 2314 ------------- |
2388 | 2315 |
2389 when Attribute_Address => Address : declare | 2316 when Attribute_Address => Address : declare |
2390 Task_Proc : Entity_Id; | 2317 Task_Proc : Entity_Id; |
2391 | 2318 |
2319 function Is_Unnested_Component_Init (N : Node_Id) return Boolean; | |
2320 -- Returns True if N is being used to initialize a component of | |
2321 -- an activation record object where the component corresponds to | |
2322 -- the object denoted by the prefix of the attribute N. | |
2323 | |
2324 function Is_Unnested_Component_Init (N : Node_Id) return Boolean is | |
2325 begin | |
2326 return Present (Parent (N)) | |
2327 and then Nkind (Parent (N)) = N_Assignment_Statement | |
2328 and then Is_Entity_Name (Pref) | |
2329 and then Present (Activation_Record_Component (Entity (Pref))) | |
2330 and then Nkind (Name (Parent (N))) = N_Selected_Component | |
2331 and then Entity (Selector_Name (Name (Parent (N)))) = | |
2332 Activation_Record_Component (Entity (Pref)); | |
2333 end Is_Unnested_Component_Init; | |
2334 | |
2335 -- Start of processing for Address | |
2336 | |
2392 begin | 2337 begin |
2393 -- If the prefix is a task or a task type, the useful address is that | 2338 -- If the prefix is a task or a task type, the useful address is that |
2394 -- of the procedure for the task body, i.e. the actual program unit. | 2339 -- of the procedure for the task body, i.e. the actual program unit. |
2395 -- We replace the original entity with that of the procedure. | 2340 -- We replace the original entity with that of the procedure. |
2396 | 2341 |
2450 | 2395 |
2451 -- Ada 2005 (AI-251): Class-wide interface objects are always | 2396 -- Ada 2005 (AI-251): Class-wide interface objects are always |
2452 -- "displaced" to reference the tag associated with the interface | 2397 -- "displaced" to reference the tag associated with the interface |
2453 -- type. In order to obtain the real address of such objects we | 2398 -- type. In order to obtain the real address of such objects we |
2454 -- generate a call to a run-time subprogram that returns the base | 2399 -- generate a call to a run-time subprogram that returns the base |
2455 -- address of the object. | 2400 -- address of the object. This call is not generated in cases where |
2456 | 2401 -- the attribute is being used to initialize a component of an |
2457 -- This processing is not needed in the VM case, where dispatching | 2402 -- activation record object where the component corresponds to |
2458 -- issues are taken care of by the virtual machine. | 2403 -- prefix of the attribute (for back ends that require "unnesting" |
2404 -- of nested subprograms), since the address needs to be assigned | |
2405 -- as-is to such components. | |
2459 | 2406 |
2460 elsif Is_Class_Wide_Type (Ptyp) | 2407 elsif Is_Class_Wide_Type (Ptyp) |
2461 and then Is_Interface (Underlying_Type (Ptyp)) | 2408 and then Is_Interface (Underlying_Type (Ptyp)) |
2462 and then Tagged_Type_Expansion | 2409 and then Tagged_Type_Expansion |
2463 and then not (Nkind (Pref) in N_Has_Entity | 2410 and then not (Nkind (Pref) in N_Has_Entity |
2464 and then Is_Subprogram (Entity (Pref))) | 2411 and then Is_Subprogram (Entity (Pref))) |
2412 and then not Is_Unnested_Component_Init (N) | |
2465 then | 2413 then |
2466 Rewrite (N, | 2414 Rewrite (N, |
2467 Make_Function_Call (Loc, | 2415 Make_Function_Call (Loc, |
2468 Name => New_Occurrence_Of (RTE (RE_Base_Address), Loc), | 2416 Name => New_Occurrence_Of (RTE (RE_Base_Address), Loc), |
2469 Parameter_Associations => New_List ( | 2417 Parameter_Associations => New_List ( |
2841 ----------------- | 2789 ----------------- |
2842 | 2790 |
2843 when Attribute_Constrained => Constrained : declare | 2791 when Attribute_Constrained => Constrained : declare |
2844 Formal_Ent : constant Entity_Id := Param_Entity (Pref); | 2792 Formal_Ent : constant Entity_Id := Param_Entity (Pref); |
2845 | 2793 |
2846 function Is_Constrained_Aliased_View (Obj : Node_Id) return Boolean; | |
2847 -- Ada 2005 (AI-363): Returns True if the object name Obj denotes a | |
2848 -- view of an aliased object whose subtype is constrained. | |
2849 | |
2850 --------------------------------- | |
2851 -- Is_Constrained_Aliased_View -- | |
2852 --------------------------------- | |
2853 | |
2854 function Is_Constrained_Aliased_View (Obj : Node_Id) return Boolean is | |
2855 E : Entity_Id; | |
2856 | |
2857 begin | |
2858 if Is_Entity_Name (Obj) then | |
2859 E := Entity (Obj); | |
2860 | |
2861 if Present (Renamed_Object (E)) then | |
2862 return Is_Constrained_Aliased_View (Renamed_Object (E)); | |
2863 else | |
2864 return Is_Aliased (E) and then Is_Constrained (Etype (E)); | |
2865 end if; | |
2866 | |
2867 else | |
2868 return Is_Aliased_View (Obj) | |
2869 and then | |
2870 (Is_Constrained (Etype (Obj)) | |
2871 or else | |
2872 (Nkind (Obj) = N_Explicit_Dereference | |
2873 and then | |
2874 not Object_Type_Has_Constrained_Partial_View | |
2875 (Typ => Base_Type (Etype (Obj)), | |
2876 Scop => Current_Scope))); | |
2877 end if; | |
2878 end Is_Constrained_Aliased_View; | |
2879 | |
2880 -- Start of processing for Constrained | 2794 -- Start of processing for Constrained |
2881 | 2795 |
2882 begin | 2796 begin |
2883 -- Reference to a parameter where the value is passed as an extra | 2797 -- Reference to a parameter where the value is passed as an extra |
2884 -- actual, corresponding to the extra formal referenced by the | 2798 -- actual, corresponding to the extra formal referenced by the |
2915 then | 2829 then |
2916 Rewrite (N, | 2830 Rewrite (N, |
2917 New_Occurrence_Of | 2831 New_Occurrence_Of |
2918 (Extra_Constrained (Entity (Pref)), Sloc (N))); | 2832 (Extra_Constrained (Entity (Pref)), Sloc (N))); |
2919 | 2833 |
2920 -- For all other entity names, we can tell at compile time | 2834 -- For all other cases, we can tell at compile time |
2921 | |
2922 elsif Is_Entity_Name (Pref) then | |
2923 declare | |
2924 Ent : constant Entity_Id := Entity (Pref); | |
2925 Res : Boolean; | |
2926 | |
2927 begin | |
2928 -- (RM J.4) obsolescent cases | |
2929 | |
2930 if Is_Type (Ent) then | |
2931 | |
2932 -- Private type | |
2933 | |
2934 if Is_Private_Type (Ent) then | |
2935 Res := not Has_Discriminants (Ent) | |
2936 or else Is_Constrained (Ent); | |
2937 | |
2938 -- It not a private type, must be a generic actual type | |
2939 -- that corresponded to a private type. We know that this | |
2940 -- correspondence holds, since otherwise the reference | |
2941 -- within the generic template would have been illegal. | |
2942 | |
2943 else | |
2944 if Is_Composite_Type (Underlying_Type (Ent)) then | |
2945 Res := Is_Constrained (Ent); | |
2946 else | |
2947 Res := True; | |
2948 end if; | |
2949 end if; | |
2950 | |
2951 else | |
2952 -- For access type, apply access check as needed | |
2953 | |
2954 if Is_Access_Type (Ptyp) then | |
2955 Apply_Access_Check (N); | |
2956 end if; | |
2957 | |
2958 -- If the prefix is not a variable or is aliased, then | |
2959 -- definitely true; if it's a formal parameter without an | |
2960 -- associated extra formal, then treat it as constrained. | |
2961 | |
2962 -- Ada 2005 (AI-363): An aliased prefix must be known to be | |
2963 -- constrained in order to set the attribute to True. | |
2964 | |
2965 if not Is_Variable (Pref) | |
2966 or else Present (Formal_Ent) | |
2967 or else (Ada_Version < Ada_2005 | |
2968 and then Is_Aliased_View (Pref)) | |
2969 or else (Ada_Version >= Ada_2005 | |
2970 and then Is_Constrained_Aliased_View (Pref)) | |
2971 then | |
2972 Res := True; | |
2973 | |
2974 -- Variable case, look at type to see if it is constrained. | |
2975 -- Note that the one case where this is not accurate (the | |
2976 -- procedure formal case), has been handled above. | |
2977 | |
2978 -- We use the Underlying_Type here (and below) in case the | |
2979 -- type is private without discriminants, but the full type | |
2980 -- has discriminants. This case is illegal, but we generate | |
2981 -- it internally for passing to the Extra_Constrained | |
2982 -- parameter. | |
2983 | |
2984 else | |
2985 -- In Ada 2012, test for case of a limited tagged type, | |
2986 -- in which case the attribute is always required to | |
2987 -- return True. The underlying type is tested, to make | |
2988 -- sure we also return True for cases where there is an | |
2989 -- unconstrained object with an untagged limited partial | |
2990 -- view which has defaulted discriminants (such objects | |
2991 -- always produce a False in earlier versions of | |
2992 -- Ada). (Ada 2012: AI05-0214) | |
2993 | |
2994 Res := | |
2995 Is_Constrained (Underlying_Type (Etype (Ent))) | |
2996 or else | |
2997 (Ada_Version >= Ada_2012 | |
2998 and then Is_Tagged_Type (Underlying_Type (Ptyp)) | |
2999 and then Is_Limited_Type (Ptyp)); | |
3000 end if; | |
3001 end if; | |
3002 | |
3003 Rewrite (N, New_Occurrence_Of (Boolean_Literals (Res), Loc)); | |
3004 end; | |
3005 | |
3006 -- Prefix is not an entity name. These are also cases where we can | |
3007 -- always tell at compile time by looking at the form and type of the | |
3008 -- prefix. If an explicit dereference of an object with constrained | |
3009 -- partial view, this is unconstrained (Ada 2005: AI95-0363). If the | |
3010 -- underlying type is a limited tagged type, then Constrained is | |
3011 -- required to always return True (Ada 2012: AI05-0214). | |
3012 | 2835 |
3013 else | 2836 else |
2837 -- For access type, apply access check as needed | |
2838 | |
2839 if Is_Entity_Name (Pref) | |
2840 and then not Is_Type (Entity (Pref)) | |
2841 and then Is_Access_Type (Ptyp) | |
2842 then | |
2843 Apply_Access_Check (N); | |
2844 end if; | |
2845 | |
3014 Rewrite (N, | 2846 Rewrite (N, |
3015 New_Occurrence_Of ( | 2847 New_Occurrence_Of |
3016 Boolean_Literals ( | 2848 (Boolean_Literals |
3017 not Is_Variable (Pref) | 2849 (Exp_Util.Attribute_Constrained_Static_Value |
3018 or else | 2850 (Pref)), Sloc (N))); |
3019 (Nkind (Pref) = N_Explicit_Dereference | |
3020 and then | |
3021 not Object_Type_Has_Constrained_Partial_View | |
3022 (Typ => Base_Type (Ptyp), | |
3023 Scop => Current_Scope)) | |
3024 or else Is_Constrained (Underlying_Type (Ptyp)) | |
3025 or else (Ada_Version >= Ada_2012 | |
3026 and then Is_Tagged_Type (Underlying_Type (Ptyp)) | |
3027 and then Is_Limited_Type (Ptyp))), | |
3028 Loc)); | |
3029 end if; | 2851 end if; |
3030 | 2852 |
3031 Analyze_And_Resolve (N, Standard_Boolean); | 2853 Analyze_And_Resolve (N, Standard_Boolean); |
3032 end Constrained; | 2854 end Constrained; |
3033 | 2855 |
3373 | 3195 |
3374 -- [constraint_error when _rep_to_pos (Y, False) = -1, msg] | 3196 -- [constraint_error when _rep_to_pos (Y, False) = -1, msg] |
3375 -- X!(Y); | 3197 -- X!(Y); |
3376 | 3198 |
3377 Expr := Unchecked_Convert_To (Ptyp, First (Exprs)); | 3199 Expr := Unchecked_Convert_To (Ptyp, First (Exprs)); |
3200 | |
3201 -- Ensure that the expression is not truncated since the "bad" bits | |
3202 -- are desired. | |
3203 | |
3204 if Nkind (Expr) = N_Unchecked_Type_Conversion then | |
3205 Set_No_Truncation (Expr); | |
3206 end if; | |
3378 | 3207 |
3379 Insert_Action (N, | 3208 Insert_Action (N, |
3380 Make_Raise_Constraint_Error (Loc, | 3209 Make_Raise_Constraint_Error (Loc, |
3381 Condition => | 3210 Condition => |
3382 Make_Op_Eq (Loc, | 3211 Make_Op_Eq (Loc, |
3624 -------------------------------- | 3453 -------------------------------- |
3625 | 3454 |
3626 -- We transform | 3455 -- We transform |
3627 | 3456 |
3628 -- fixtype'Fixed_Value (integer-value) | 3457 -- fixtype'Fixed_Value (integer-value) |
3629 -- inttype'Fixed_Value (fixed-value) | 3458 -- inttype'Integer_Value (fixed-value) |
3630 | 3459 |
3631 -- into | 3460 -- into |
3632 | 3461 |
3633 -- fixtype (integer-value) | 3462 -- fixtype (integer-value) |
3634 -- inttype (fixed-value) | 3463 -- inttype (fixed-value) |
3635 | 3464 |
3636 -- respectively. | 3465 -- respectively. |
3637 | 3466 |
3638 -- We do all the required analysis of the conversion here, because we do | 3467 -- We set Conversion_OK on the conversion because we do not want it |
3639 -- not want this to go through the fixed-point conversion circuits. Note | 3468 -- to go through the fixed-point conversion circuits. |
3640 -- that the back end always treats fixed-point as equivalent to the | |
3641 -- corresponding integer type anyway. | |
3642 -- However, in order to remove the handling of Do_Range_Check from the | |
3643 -- backend, we force the generation of a check on the result by | |
3644 -- setting the result type appropriately. Apply_Conversion_Checks | |
3645 -- will generate the required expansion. | |
3646 | 3469 |
3647 when Attribute_Fixed_Value | 3470 when Attribute_Fixed_Value |
3648 | Attribute_Integer_Value | 3471 | Attribute_Integer_Value |
3649 => | 3472 => |
3650 Rewrite (N, | 3473 Rewrite (N, OK_Convert_To (Entity (Pref), First (Exprs))); |
3651 Make_Type_Conversion (Loc, | 3474 |
3652 Subtype_Mark => New_Occurrence_Of (Entity (Pref), Loc), | 3475 -- Note that it might appear that a properly analyzed unchecked |
3653 Expression => Relocate_Node (First (Exprs)))); | 3476 -- conversion would be just fine here, but that's not the case, |
3654 | 3477 -- since the full range checks performed by the following calls |
3655 -- Indicate that the result of the conversion may require a | 3478 -- are critical. |
3656 -- range check (see below); | 3479 |
3657 | 3480 Apply_Type_Conversion_Checks (N); |
3658 Set_Etype (N, Base_Type (Entity (Pref))); | 3481 |
3482 -- Note that Apply_Type_Conversion_Checks only deals with the | |
3483 -- overflow checks on conversions involving fixed-point types | |
3484 -- so we must apply range checks manually on them and expand. | |
3485 | |
3486 Apply_Scalar_Range_Check | |
3487 (Expression (N), Etype (N), Fixed_Int => True); | |
3488 | |
3659 Set_Analyzed (N); | 3489 Set_Analyzed (N); |
3660 | 3490 Expand (N); |
3661 -- Note: it might appear that a properly analyzed unchecked | |
3662 -- conversion would be just fine here, but that's not the case, | |
3663 -- since the full range checks performed by the following code | |
3664 -- are critical. | |
3665 -- Given that Fixed-point conversions are not further expanded | |
3666 -- to prevent the involvement of real type operations we have to | |
3667 -- construct two checks explicitly: one on the operand, and one | |
3668 -- on the result. This used to be done in part in the back-end, | |
3669 -- but for other targets (E.g. LLVM) it is preferable to create | |
3670 -- the tests in full in the front-end. | |
3671 | |
3672 if Is_Fixed_Point_Type (Etype (N)) then | |
3673 declare | |
3674 Loc : constant Source_Ptr := Sloc (N); | |
3675 Equiv_T : constant Entity_Id := Make_Temporary (Loc, 'T', N); | |
3676 Expr : constant Node_Id := Expression (N); | |
3677 Fst : constant Entity_Id := Root_Type (Etype (N)); | |
3678 Decl : Node_Id; | |
3679 | |
3680 begin | |
3681 Decl := | |
3682 Make_Full_Type_Declaration (Sloc (N), | |
3683 Defining_Identifier => Equiv_T, | |
3684 Type_Definition => | |
3685 Make_Signed_Integer_Type_Definition (Loc, | |
3686 Low_Bound => | |
3687 Make_Integer_Literal (Loc, | |
3688 Intval => | |
3689 Corresponding_Integer_Value | |
3690 (Type_Low_Bound (Fst))), | |
3691 High_Bound => | |
3692 Make_Integer_Literal (Loc, | |
3693 Intval => | |
3694 Corresponding_Integer_Value | |
3695 (Type_High_Bound (Fst))))); | |
3696 Insert_Action (N, Decl); | |
3697 | |
3698 -- Verify that the conversion is possible | |
3699 | |
3700 Generate_Range_Check (Expr, Equiv_T, CE_Overflow_Check_Failed); | |
3701 | |
3702 -- and verify that the result is in range | |
3703 | |
3704 Generate_Range_Check (N, Etype (N), CE_Range_Check_Failed); | |
3705 end; | |
3706 end if; | |
3707 | 3491 |
3708 ----------- | 3492 ----------- |
3709 -- Floor -- | 3493 -- Floor -- |
3710 ----------- | 3494 ----------- |
3711 | 3495 |
3726 -- expands into | 3510 -- expands into |
3727 | 3511 |
3728 -- Result_Type (System.Fore (Universal_Real (Type'First)), | 3512 -- Result_Type (System.Fore (Universal_Real (Type'First)), |
3729 -- Universal_Real (Type'Last)) | 3513 -- Universal_Real (Type'Last)) |
3730 | 3514 |
3731 -- Note that we know that the type is a non-static subtype, or Fore | 3515 -- Note that we know that the type is a nonstatic subtype, or Fore would |
3732 -- would have itself been computed dynamically in Eval_Attribute. | 3516 -- have itself been computed dynamically in Eval_Attribute. |
3733 | 3517 |
3734 when Attribute_Fore => | 3518 when Attribute_Fore => |
3735 Rewrite (N, | 3519 Rewrite (N, |
3736 Convert_To (Typ, | 3520 Convert_To (Typ, |
3737 Make_Function_Call (Loc, | 3521 Make_Function_Call (Loc, |
4092 return; | 3876 return; |
4093 end if; | 3877 end if; |
4094 | 3878 |
4095 declare | 3879 declare |
4096 Rtyp : constant Entity_Id := Root_Type (P_Type); | 3880 Rtyp : constant Entity_Id := Root_Type (P_Type); |
4097 Expr : Node_Id; | 3881 |
3882 Expr : Node_Id; -- call to Descendant_Tag | |
3883 Get_Tag : Node_Id; -- expression to read the 'Tag | |
4098 | 3884 |
4099 begin | 3885 begin |
4100 -- Read the internal tag (RM 13.13.2(34)) and use it to | 3886 -- Read the internal tag (RM 13.13.2(34)) and use it to |
4101 -- initialize a dummy tag value. We used to generate: | 3887 -- initialize a dummy tag value. We used to unconditionally |
3888 -- generate: | |
4102 -- | 3889 -- |
4103 -- Descendant_Tag (String'Input (Strm), P_Type); | 3890 -- Descendant_Tag (String'Input (Strm), P_Type); |
4104 -- | 3891 -- |
4105 -- which turns into a call to String_Input_Blk_IO. However, | 3892 -- which turns into a call to String_Input_Blk_IO. However, |
4106 -- if the input is malformed, that could try to read an | 3893 -- if the input is malformed, that could try to read an |
4107 -- enormous String, causing chaos. So instead we call | 3894 -- enormous String, causing chaos. So instead we call |
4108 -- String_Input_Tag, which does the same thing as | 3895 -- String_Input_Tag, which does the same thing as |
4109 -- String_Input_Blk_IO, except that if the String is | 3896 -- String_Input_Blk_IO, except that if the String is |
4110 -- absurdly long, it raises an exception. | 3897 -- absurdly long, it raises an exception. |
4111 -- | 3898 -- |
3899 -- However, if the No_Stream_Optimizations restriction | |
3900 -- is active, we disable this unnecessary attempt at | |
3901 -- robustness; we really need to read the string | |
3902 -- character-by-character. | |
3903 -- | |
4112 -- This value is used only to provide a controlling | 3904 -- This value is used only to provide a controlling |
4113 -- argument for the eventual _Input call. Descendant_Tag is | 3905 -- argument for the eventual _Input call. Descendant_Tag is |
4114 -- called rather than Internal_Tag to ensure that we have a | 3906 -- called rather than Internal_Tag to ensure that we have a |
4115 -- tag for a type that is descended from the prefix type and | 3907 -- tag for a type that is descended from the prefix type and |
4116 -- declared at the same accessibility level (the exception | 3908 -- declared at the same accessibility level (the exception |
4121 -- Note: we used to generate an explicit declaration of a | 3913 -- Note: we used to generate an explicit declaration of a |
4122 -- constant Ada.Tags.Tag object, and use an occurrence of | 3914 -- constant Ada.Tags.Tag object, and use an occurrence of |
4123 -- this constant in Cntrl, but this caused a secondary stack | 3915 -- this constant in Cntrl, but this caused a secondary stack |
4124 -- leak. | 3916 -- leak. |
4125 | 3917 |
3918 if Restriction_Active (No_Stream_Optimizations) then | |
3919 Get_Tag := | |
3920 Make_Attribute_Reference (Loc, | |
3921 Prefix => | |
3922 New_Occurrence_Of (Standard_String, Loc), | |
3923 Attribute_Name => Name_Input, | |
3924 Expressions => New_List ( | |
3925 Relocate_Node (Duplicate_Subexpr (Strm)))); | |
3926 else | |
3927 Get_Tag := | |
3928 Make_Function_Call (Loc, | |
3929 Name => | |
3930 New_Occurrence_Of | |
3931 (RTE (RE_String_Input_Tag), Loc), | |
3932 Parameter_Associations => New_List ( | |
3933 Relocate_Node (Duplicate_Subexpr (Strm)))); | |
3934 end if; | |
3935 | |
4126 Expr := | 3936 Expr := |
4127 Make_Function_Call (Loc, | 3937 Make_Function_Call (Loc, |
4128 Name => | 3938 Name => |
4129 New_Occurrence_Of (RTE (RE_Descendant_Tag), Loc), | 3939 New_Occurrence_Of (RTE (RE_Descendant_Tag), Loc), |
4130 Parameter_Associations => New_List ( | 3940 Parameter_Associations => New_List ( |
4131 Make_Function_Call (Loc, | 3941 Get_Tag, |
4132 Name => | |
4133 New_Occurrence_Of | |
4134 (RTE (RE_String_Input_Tag), Loc), | |
4135 Parameter_Associations => New_List ( | |
4136 Relocate_Node (Duplicate_Subexpr (Strm)))), | |
4137 | |
4138 Make_Attribute_Reference (Loc, | 3942 Make_Attribute_Reference (Loc, |
4139 Prefix => New_Occurrence_Of (P_Type, Loc), | 3943 Prefix => New_Occurrence_Of (P_Type, Loc), |
4140 Attribute_Name => Name_Tag))); | 3944 Attribute_Name => Name_Tag))); |
4141 | 3945 |
4142 Set_Etype (Expr, RTE (RE_Tag)); | 3946 Set_Etype (Expr, RTE (RE_Tag)); |
4239 -- Invalid_Value -- | 4043 -- Invalid_Value -- |
4240 ------------------- | 4044 ------------------- |
4241 | 4045 |
4242 when Attribute_Invalid_Value => | 4046 when Attribute_Invalid_Value => |
4243 Rewrite (N, Get_Simple_Init_Val (Ptyp, N)); | 4047 Rewrite (N, Get_Simple_Init_Val (Ptyp, N)); |
4048 | |
4049 -- The value produced may be a conversion of a literal, which must be | |
4050 -- resolved to establish its proper type. | |
4051 | |
4052 Analyze_And_Resolve (N); | |
4244 | 4053 |
4245 ---------- | 4054 ---------- |
4246 -- Last -- | 4055 -- Last -- |
4247 ---------- | 4056 ---------- |
4248 | 4057 |
5435 Right_Opnd => | 5244 Right_Opnd => |
5436 Make_Integer_Literal (Loc, 1))), | 5245 Make_Integer_Literal (Loc, 1))), |
5437 Rep_To_Pos_Flag (Ptyp, Loc)))))); | 5246 Rep_To_Pos_Flag (Ptyp, Loc)))))); |
5438 | 5247 |
5439 else | 5248 else |
5440 -- Add Boolean parameter True, to request program errror if | 5249 -- Add Boolean parameter True, to request program error if |
5441 -- we have a bad representation on our hands. If checks are | 5250 -- we have a bad representation on our hands. If checks are |
5442 -- suppressed, then add False instead | 5251 -- suppressed, then add False instead |
5443 | 5252 |
5444 Append_To (Exprs, Rep_To_Pos_Flag (Ptyp, Loc)); | 5253 Append_To (Exprs, Rep_To_Pos_Flag (Ptyp, Loc)); |
5445 Rewrite (N, | 5254 Rewrite (N, |
5652 | 5461 |
5653 else | 5462 else |
5654 Apply_Universal_Integer_Attribute_Checks (N); | 5463 Apply_Universal_Integer_Attribute_Checks (N); |
5655 end if; | 5464 end if; |
5656 | 5465 |
5466 ------------ | |
5467 -- Reduce -- | |
5468 ------------ | |
5469 | |
5470 when Attribute_Reduce => | |
5471 declare | |
5472 Loc : constant Source_Ptr := Sloc (N); | |
5473 E1 : constant Node_Id := First (Expressions (N)); | |
5474 E2 : constant Node_Id := Next (E1); | |
5475 Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); | |
5476 Typ : constant Entity_Id := Etype (N); | |
5477 New_Loop : Node_Id; | |
5478 | |
5479 -- If the prefix is an aggregwte, its unique component is sn | |
5480 -- Iterated_Element, and we create a loop out of its itertor. | |
5481 | |
5482 begin | |
5483 if Nkind (Prefix (N)) = N_Aggregate then | |
5484 declare | |
5485 Stream : constant Node_Id := | |
5486 First (Component_Associations (Prefix (N))); | |
5487 Id : constant Node_Id := Defining_Identifier (Stream); | |
5488 Expr : constant Node_Id := Expression (Stream); | |
5489 Ch : constant Node_Id := | |
5490 First (Discrete_Choices (Stream)); | |
5491 begin | |
5492 New_Loop := Make_Loop_Statement (Loc, | |
5493 Iteration_Scheme => | |
5494 Make_Iteration_Scheme (Loc, | |
5495 Iterator_Specification => Empty, | |
5496 Loop_Parameter_Specification => | |
5497 Make_Loop_Parameter_Specification (Loc, | |
5498 Defining_Identifier => New_Copy (Id), | |
5499 Discrete_Subtype_Definition => | |
5500 Relocate_Node (Ch))), | |
5501 End_Label => Empty, | |
5502 Statements => New_List ( | |
5503 Make_Assignment_Statement (Loc, | |
5504 Name => New_Occurrence_Of (Bnn, Loc), | |
5505 Expression => Make_Function_Call (Loc, | |
5506 Name => New_Occurrence_Of (Entity (E1), Loc), | |
5507 Parameter_Associations => New_List ( | |
5508 New_Occurrence_Of (Bnn, Loc), | |
5509 Relocate_Node (Expr)))))); | |
5510 end; | |
5511 else | |
5512 -- If the prefix is a name we construct an element iterwtor | |
5513 -- over it. Its expansion will verify that it is an array | |
5514 -- or a container with the proper aspects. | |
5515 | |
5516 declare | |
5517 Iter : Node_Id; | |
5518 Elem : constant Entity_Id := Make_Temporary (Loc, 'E', N); | |
5519 | |
5520 begin | |
5521 Iter := | |
5522 Make_Iterator_Specification (Loc, | |
5523 Defining_Identifier => Elem, | |
5524 Name => Relocate_Node (Prefix (N)), | |
5525 Subtype_Indication => Empty); | |
5526 Set_Of_Present (Iter); | |
5527 | |
5528 New_Loop := Make_Loop_Statement (Loc, | |
5529 Iteration_Scheme => | |
5530 Make_Iteration_Scheme (Loc, | |
5531 Iterator_Specification => Iter, | |
5532 Loop_Parameter_Specification => Empty), | |
5533 End_Label => Empty, | |
5534 Statements => New_List ( | |
5535 Make_Assignment_Statement (Loc, | |
5536 Name => New_Occurrence_Of (Bnn, Loc), | |
5537 Expression => Make_Function_Call (Loc, | |
5538 Name => New_Occurrence_Of (Entity (E1), Loc), | |
5539 Parameter_Associations => New_List ( | |
5540 New_Occurrence_Of (Bnn, Loc), | |
5541 New_Occurrence_Of (Elem, Loc)))))); | |
5542 end; | |
5543 end if; | |
5544 | |
5545 Rewrite (N, | |
5546 Make_Expression_With_Actions (Loc, | |
5547 Actions => New_List ( | |
5548 Make_Object_Declaration (Loc, | |
5549 Defining_Identifier => Bnn, | |
5550 Object_Definition => | |
5551 New_Occurrence_Of (Typ, Loc), | |
5552 Expression => Relocate_Node (E2)), New_Loop), | |
5553 Expression => New_Occurrence_Of (Bnn, Loc))); | |
5554 Analyze_And_Resolve (N, Typ); | |
5555 end; | |
5556 | |
5657 ---------- | 5557 ---------- |
5658 -- Read -- | 5558 -- Read -- |
5659 ---------- | 5559 ---------- |
5660 | 5560 |
5661 when Attribute_Read => Read : declare | 5561 when Attribute_Read => Read : declare |
5952 | Attribute_Size | 5852 | Attribute_Size |
5953 | Attribute_Value_Size | 5853 | Attribute_Value_Size |
5954 | Attribute_VADS_Size | 5854 | Attribute_VADS_Size |
5955 => | 5855 => |
5956 Size : declare | 5856 Size : declare |
5957 Siz : Uint; | |
5958 New_Node : Node_Id; | 5857 New_Node : Node_Id; |
5959 | 5858 |
5960 begin | 5859 begin |
5961 -- Processing for VADS_Size case. Note that this processing | 5860 -- Processing for VADS_Size case. Note that this processing |
5962 -- removes all traces of VADS_Size from the tree, and completes | 5861 -- removes all traces of VADS_Size from the tree, and completes |
6064 end if; | 5963 end if; |
6065 | 5964 |
6066 Rewrite (N, New_Node); | 5965 Rewrite (N, New_Node); |
6067 Analyze_And_Resolve (N, Typ); | 5966 Analyze_And_Resolve (N, Typ); |
6068 return; | 5967 return; |
6069 | |
6070 -- Case of known RM_Size of a type | |
6071 | |
6072 elsif (Id = Attribute_Size or else Id = Attribute_Value_Size) | |
6073 and then Is_Entity_Name (Pref) | |
6074 and then Is_Type (Entity (Pref)) | |
6075 and then Known_Static_RM_Size (Entity (Pref)) | |
6076 then | |
6077 Siz := RM_Size (Entity (Pref)); | |
6078 | |
6079 -- Case of known Esize of a type | |
6080 | |
6081 elsif Id = Attribute_Object_Size | |
6082 and then Is_Entity_Name (Pref) | |
6083 and then Is_Type (Entity (Pref)) | |
6084 and then Known_Static_Esize (Entity (Pref)) | |
6085 then | |
6086 Siz := Esize (Entity (Pref)); | |
6087 | |
6088 -- Case of known size of object | |
6089 | |
6090 elsif Id = Attribute_Size | |
6091 and then Is_Entity_Name (Pref) | |
6092 and then Is_Object (Entity (Pref)) | |
6093 and then Known_Esize (Entity (Pref)) | |
6094 and then Known_Static_Esize (Entity (Pref)) | |
6095 then | |
6096 Siz := Esize (Entity (Pref)); | |
6097 | |
6098 -- For an array component, we can do Size in the front end if the | |
6099 -- component_size of the array is set. | |
6100 | |
6101 elsif Nkind (Pref) = N_Indexed_Component then | |
6102 Siz := Component_Size (Etype (Prefix (Pref))); | |
6103 | |
6104 -- For a record component, we can do Size in the front end if | |
6105 -- there is a component clause, or if the record is packed and the | |
6106 -- component's size is known at compile time. | |
6107 | |
6108 elsif Nkind (Pref) = N_Selected_Component then | |
6109 declare | |
6110 Rec : constant Entity_Id := Etype (Prefix (Pref)); | |
6111 Comp : constant Entity_Id := Entity (Selector_Name (Pref)); | |
6112 | |
6113 begin | |
6114 if Present (Component_Clause (Comp)) then | |
6115 Siz := Esize (Comp); | |
6116 | |
6117 elsif Is_Packed (Rec) then | |
6118 Siz := RM_Size (Ptyp); | |
6119 | |
6120 else | |
6121 Apply_Universal_Integer_Attribute_Checks (N); | |
6122 return; | |
6123 end if; | |
6124 end; | |
6125 | |
6126 -- All other cases are handled by the back end | |
6127 | |
6128 else | |
6129 Apply_Universal_Integer_Attribute_Checks (N); | |
6130 | |
6131 -- If Size is applied to a formal parameter that is of a packed | |
6132 -- array subtype, then apply Size to the actual subtype. | |
6133 | |
6134 if Is_Entity_Name (Pref) | |
6135 and then Is_Formal (Entity (Pref)) | |
6136 and then Is_Array_Type (Ptyp) | |
6137 and then Is_Packed (Ptyp) | |
6138 then | |
6139 Rewrite (N, | |
6140 Make_Attribute_Reference (Loc, | |
6141 Prefix => | |
6142 New_Occurrence_Of (Get_Actual_Subtype (Pref), Loc), | |
6143 Attribute_Name => Name_Size)); | |
6144 Analyze_And_Resolve (N, Typ); | |
6145 end if; | |
6146 | |
6147 -- If Size applies to a dereference of an access to | |
6148 -- unconstrained packed array, the back end needs to see its | |
6149 -- unconstrained nominal type, but also a hint to the actual | |
6150 -- constrained type. | |
6151 | |
6152 if Nkind (Pref) = N_Explicit_Dereference | |
6153 and then Is_Array_Type (Ptyp) | |
6154 and then not Is_Constrained (Ptyp) | |
6155 and then Is_Packed (Ptyp) | |
6156 then | |
6157 Set_Actual_Designated_Subtype (Pref, | |
6158 Get_Actual_Subtype (Pref)); | |
6159 end if; | |
6160 | |
6161 return; | |
6162 end if; | 5968 end if; |
6163 | 5969 |
6164 -- Common processing for record and array component case | 5970 -- Call Expand_Size_Attribute to do the final part of the |
6165 | 5971 -- expansion which is shared with GNATprove expansion. |
6166 if Siz /= No_Uint and then Siz /= 0 then | 5972 |
6167 declare | 5973 Expand_Size_Attribute (N); |
6168 CS : constant Boolean := Comes_From_Source (N); | |
6169 | |
6170 begin | |
6171 Rewrite (N, Make_Integer_Literal (Loc, Siz)); | |
6172 | |
6173 -- This integer literal is not a static expression. We do | |
6174 -- not call Analyze_And_Resolve here, because this would | |
6175 -- activate the circuit for deciding that a static value | |
6176 -- was out of range, and we don't want that. | |
6177 | |
6178 -- So just manually set the type, mark the expression as | |
6179 -- non-static, and then ensure that the result is checked | |
6180 -- properly if the attribute comes from source (if it was | |
6181 -- internally generated, we never need a constraint check). | |
6182 | |
6183 Set_Etype (N, Typ); | |
6184 Set_Is_Static_Expression (N, False); | |
6185 | |
6186 if CS then | |
6187 Apply_Constraint_Check (N, Typ); | |
6188 end if; | |
6189 end; | |
6190 end if; | |
6191 end Size; | 5974 end Size; |
6192 | 5975 |
6193 ------------------ | 5976 ------------------ |
6194 -- Storage_Pool -- | 5977 -- Storage_Pool -- |
6195 ------------------ | 5978 ------------------ |
6431 Relocate_Node (First (Exprs))), | 6214 Relocate_Node (First (Exprs))), |
6432 Right_Opnd => | 6215 Right_Opnd => |
6433 Make_Integer_Literal (Loc, 1))), | 6216 Make_Integer_Literal (Loc, 1))), |
6434 Rep_To_Pos_Flag (Ptyp, Loc)))))); | 6217 Rep_To_Pos_Flag (Ptyp, Loc)))))); |
6435 else | 6218 else |
6436 -- Add Boolean parameter True, to request program errror if | 6219 -- Add Boolean parameter True, to request program error if |
6437 -- we have a bad representation on our hands. Add False if | 6220 -- we have a bad representation on our hands. Add False if |
6438 -- checks are suppressed. | 6221 -- checks are suppressed. |
6439 | 6222 |
6440 Append_To (Exprs, Rep_To_Pos_Flag (Ptyp, Loc)); | 6223 Append_To (Exprs, Rep_To_Pos_Flag (Ptyp, Loc)); |
6441 Rewrite (N, | 6224 Rewrite (N, |
6603 ---------------- | 6386 ---------------- |
6604 -- To_Address -- | 6387 -- To_Address -- |
6605 ---------------- | 6388 ---------------- |
6606 | 6389 |
6607 -- Transforms System'To_Address (X) and System.Address'Ref (X) into | 6390 -- Transforms System'To_Address (X) and System.Address'Ref (X) into |
6608 -- unchecked conversion from (integral) type of X to type address. | 6391 -- unchecked conversion from (integral) type of X to type address. If |
6392 -- the To_Address is a static expression, the transformed expression | |
6393 -- also needs to be static, because we do some legality checks (e.g. | |
6394 -- for Thread_Local_Storage) after this transformation. | |
6609 | 6395 |
6610 when Attribute_Ref | 6396 when Attribute_Ref |
6611 | Attribute_To_Address | 6397 | Attribute_To_Address |
6612 => | 6398 => |
6613 Rewrite (N, | 6399 To_Address : declare |
6614 Unchecked_Convert_To (RTE (RE_Address), | 6400 Is_Static : constant Boolean := Is_Static_Expression (N); |
6615 Relocate_Node (First (Exprs)))); | 6401 |
6616 Analyze_And_Resolve (N, RTE (RE_Address)); | 6402 begin |
6403 Rewrite (N, | |
6404 Unchecked_Convert_To (RTE (RE_Address), | |
6405 Relocate_Node (First (Exprs)))); | |
6406 Set_Is_Static_Expression (N, Is_Static); | |
6407 | |
6408 Analyze_And_Resolve (N, RTE (RE_Address)); | |
6409 end To_Address; | |
6617 | 6410 |
6618 ------------ | 6411 ------------ |
6619 -- To_Any -- | 6412 -- To_Any -- |
6620 ------------ | 6413 ------------ |
6621 | 6414 |
6755 | 6548 |
6756 -- The code for valid is dependent on the particular types involved. | 6549 -- The code for valid is dependent on the particular types involved. |
6757 -- See separate sections below for the generated code in each case. | 6550 -- See separate sections below for the generated code in each case. |
6758 | 6551 |
6759 when Attribute_Valid => Valid : declare | 6552 when Attribute_Valid => Valid : declare |
6760 Btyp : Entity_Id := Base_Type (Ptyp); | 6553 PBtyp : Entity_Id := Base_Type (Ptyp); |
6761 | 6554 |
6762 Save_Validity_Checks_On : constant Boolean := Validity_Checks_On; | 6555 Save_Validity_Checks_On : constant Boolean := Validity_Checks_On; |
6763 -- Save the validity checking mode. We always turn off validity | 6556 -- Save the validity checking mode. We always turn off validity |
6764 -- checking during process of 'Valid since this is one place | 6557 -- checking during process of 'Valid since this is one place |
6765 -- where we do not want the implicit validity checks to interfere | 6558 -- where we do not want the implicit validity checks to interfere |
6766 -- with the explicit validity check that the programmer is doing. | 6559 -- with the explicit validity check that the programmer is doing. |
6767 | 6560 |
6768 function Make_Range_Test return Node_Id; | 6561 function Make_Range_Test return Node_Id; |
6769 -- Build the code for a range test of the form | 6562 -- Build the code for a range test of the form |
6770 -- Btyp!(Pref) in Btyp!(Ptyp'First) .. Btyp!(Ptyp'Last) | 6563 -- PBtyp!(Pref) in PBtyp!(Ptyp'First) .. PBtyp!(Ptyp'Last) |
6771 | 6564 |
6772 --------------------- | 6565 --------------------- |
6773 -- Make_Range_Test -- | 6566 -- Make_Range_Test -- |
6774 --------------------- | 6567 --------------------- |
6775 | 6568 |
6804 Temp := Duplicate_Subexpr (Pref); | 6597 Temp := Duplicate_Subexpr (Pref); |
6805 end if; | 6598 end if; |
6806 | 6599 |
6807 return | 6600 return |
6808 Make_In (Loc, | 6601 Make_In (Loc, |
6809 Left_Opnd => Unchecked_Convert_To (Btyp, Temp), | 6602 Left_Opnd => Unchecked_Convert_To (PBtyp, Temp), |
6810 Right_Opnd => | 6603 Right_Opnd => |
6811 Make_Range (Loc, | 6604 Make_Range (Loc, |
6812 Low_Bound => | 6605 Low_Bound => |
6813 Unchecked_Convert_To (Btyp, | 6606 Unchecked_Convert_To (PBtyp, |
6814 Make_Attribute_Reference (Loc, | 6607 Make_Attribute_Reference (Loc, |
6815 Prefix => New_Occurrence_Of (Ptyp, Loc), | 6608 Prefix => New_Occurrence_Of (Ptyp, Loc), |
6816 Attribute_Name => Name_First)), | 6609 Attribute_Name => Name_First)), |
6817 High_Bound => | 6610 High_Bound => |
6818 Unchecked_Convert_To (Btyp, | 6611 Unchecked_Convert_To (PBtyp, |
6819 Make_Attribute_Reference (Loc, | 6612 Make_Attribute_Reference (Loc, |
6820 Prefix => New_Occurrence_Of (Ptyp, Loc), | 6613 Prefix => New_Occurrence_Of (Ptyp, Loc), |
6821 Attribute_Name => Name_Last)))); | 6614 Attribute_Name => Name_Last)))); |
6822 end Make_Range_Test; | 6615 end Make_Range_Test; |
6823 | 6616 |
6841 Validity_Checks_On := False; | 6634 Validity_Checks_On := False; |
6842 | 6635 |
6843 -- Retrieve the base type. Handle the case where the base type is a | 6636 -- Retrieve the base type. Handle the case where the base type is a |
6844 -- private enumeration type. | 6637 -- private enumeration type. |
6845 | 6638 |
6846 if Is_Private_Type (Btyp) and then Present (Full_View (Btyp)) then | 6639 if Is_Private_Type (PBtyp) and then Present (Full_View (PBtyp)) then |
6847 Btyp := Full_View (Btyp); | 6640 PBtyp := Full_View (PBtyp); |
6848 end if; | 6641 end if; |
6849 | 6642 |
6850 -- Floating-point case. This case is handled by the Valid attribute | 6643 -- Floating-point case. This case is handled by the Valid attribute |
6851 -- code in the floating-point attribute run-time library. | 6644 -- code in the floating-point attribute run-time library. |
6852 | 6645 |
6875 -- Start of processing for Float_Valid | 6668 -- Start of processing for Float_Valid |
6876 | 6669 |
6877 begin | 6670 begin |
6878 -- The C and AAMP back-ends handle Valid for fpt types | 6671 -- The C and AAMP back-ends handle Valid for fpt types |
6879 | 6672 |
6880 if Modify_Tree_For_C or else Float_Rep (Btyp) = AAMP then | 6673 if Modify_Tree_For_C or else Float_Rep (PBtyp) = AAMP then |
6881 Analyze_And_Resolve (Pref, Ptyp); | 6674 Analyze_And_Resolve (Pref, Ptyp); |
6882 Set_Etype (N, Standard_Boolean); | 6675 Set_Etype (N, Standard_Boolean); |
6883 Set_Analyzed (N); | 6676 Set_Analyzed (N); |
6884 | 6677 |
6885 else | 6678 else |
6968 -- catches infinities properly (infinities are never valid). | 6761 -- catches infinities properly (infinities are never valid). |
6969 | 6762 |
6970 -- The way we do the range check is simply to create the | 6763 -- The way we do the range check is simply to create the |
6971 -- expression: Valid (N) and then Base_Type(Pref) in Typ. | 6764 -- expression: Valid (N) and then Base_Type(Pref) in Typ. |
6972 | 6765 |
6973 if not Subtypes_Statically_Match (Ptyp, Btyp) then | 6766 if not Subtypes_Statically_Match (Ptyp, PBtyp) then |
6974 Rewrite (N, | 6767 Rewrite (N, |
6975 Make_And_Then (Loc, | 6768 Make_And_Then (Loc, |
6976 Left_Opnd => Relocate_Node (N), | 6769 Left_Opnd => Relocate_Node (N), |
6977 Right_Opnd => | 6770 Right_Opnd => |
6978 Make_In (Loc, | 6771 Make_In (Loc, |
6979 Left_Opnd => Convert_To (Btyp, Pref), | 6772 Left_Opnd => Convert_To (PBtyp, Pref), |
6980 Right_Opnd => New_Occurrence_Of (Ptyp, Loc)))); | 6773 Right_Opnd => New_Occurrence_Of (Ptyp, Loc)))); |
6981 end if; | 6774 end if; |
6982 end Float_Valid; | 6775 end Float_Valid; |
6983 | 6776 |
6984 -- Enumeration type with holes | 6777 -- Enumeration type with holes |
7003 -- _rep_to_pos (X, False) >= 0 | 6796 -- _rep_to_pos (X, False) >= 0 |
7004 -- and then | 6797 -- and then |
7005 -- (X >= type(X)'First and then type(X)'Last <= X) | 6798 -- (X >= type(X)'First and then type(X)'Last <= X) |
7006 | 6799 |
7007 elsif Is_Enumeration_Type (Ptyp) | 6800 elsif Is_Enumeration_Type (Ptyp) |
7008 and then Present (Enum_Pos_To_Rep (Btyp)) | 6801 and then Present (Enum_Pos_To_Rep (PBtyp)) |
7009 then | 6802 then |
7010 Tst := | 6803 Tst := |
7011 Make_Op_Ge (Loc, | 6804 Make_Op_Ge (Loc, |
7012 Left_Opnd => | 6805 Left_Opnd => |
7013 Make_Function_Call (Loc, | 6806 Make_Function_Call (Loc, |
7014 Name => | 6807 Name => |
7015 New_Occurrence_Of (TSS (Btyp, TSS_Rep_To_Pos), Loc), | 6808 New_Occurrence_Of (TSS (PBtyp, TSS_Rep_To_Pos), Loc), |
7016 Parameter_Associations => New_List ( | 6809 Parameter_Associations => New_List ( |
7017 Pref, | 6810 Pref, |
7018 New_Occurrence_Of (Standard_False, Loc))), | 6811 New_Occurrence_Of (Standard_False, Loc))), |
7019 Right_Opnd => Make_Integer_Literal (Loc, 0)); | 6812 Right_Opnd => Make_Integer_Literal (Loc, 0)); |
7020 | 6813 |
7021 if Ptyp /= Btyp | 6814 if Ptyp /= PBtyp |
7022 and then | 6815 and then |
7023 (Type_Low_Bound (Ptyp) /= Type_Low_Bound (Btyp) | 6816 (Type_Low_Bound (Ptyp) /= Type_Low_Bound (PBtyp) |
7024 or else | 6817 or else |
7025 Type_High_Bound (Ptyp) /= Type_High_Bound (Btyp)) | 6818 Type_High_Bound (Ptyp) /= Type_High_Bound (PBtyp)) |
7026 then | 6819 then |
7027 -- The call to Make_Range_Test will create declarations | 6820 -- The call to Make_Range_Test will create declarations |
7028 -- that need a proper insertion point, but Pref is now | 6821 -- that need a proper insertion point, but Pref is now |
7029 -- attached to a node with no ancestor. Attach to tree | 6822 -- attached to a node with no ancestor. Attach to tree |
7030 -- even if it is to be rewritten below. | 6823 -- even if it is to be rewritten below. |
7053 -- For biased representations, we will be doing an unchecked | 6846 -- For biased representations, we will be doing an unchecked |
7054 -- conversion without unbiasing the result. That means that the range | 6847 -- conversion without unbiasing the result. That means that the range |
7055 -- test has to take this into account, and the proper form of the | 6848 -- test has to take this into account, and the proper form of the |
7056 -- test is: | 6849 -- test is: |
7057 | 6850 |
7058 -- Btyp!(Pref) < Btyp!(Ptyp'Range_Length) | 6851 -- PBtyp!(Pref) < PBtyp!(Ptyp'Range_Length) |
7059 | 6852 |
7060 elsif Has_Biased_Representation (Ptyp) then | 6853 elsif Has_Biased_Representation (Ptyp) then |
7061 Btyp := RTE (RE_Unsigned_32); | 6854 PBtyp := RTE (RE_Unsigned_32); |
7062 Rewrite (N, | 6855 Rewrite (N, |
7063 Make_Op_Lt (Loc, | 6856 Make_Op_Lt (Loc, |
7064 Left_Opnd => | 6857 Left_Opnd => |
7065 Unchecked_Convert_To (Btyp, Duplicate_Subexpr (Pref)), | 6858 Unchecked_Convert_To (PBtyp, Duplicate_Subexpr (Pref)), |
7066 Right_Opnd => | 6859 Right_Opnd => |
7067 Unchecked_Convert_To (Btyp, | 6860 Unchecked_Convert_To (PBtyp, |
7068 Make_Attribute_Reference (Loc, | 6861 Make_Attribute_Reference (Loc, |
7069 Prefix => New_Occurrence_Of (Ptyp, Loc), | 6862 Prefix => New_Occurrence_Of (Ptyp, Loc), |
7070 Attribute_Name => Name_Range_Length)))); | 6863 Attribute_Name => Name_Range_Length)))); |
7071 | 6864 |
7072 -- For all other scalar types, what we want logically is a | 6865 -- For all other scalar types, what we want logically is a |
7077 -- But that's precisely what won't work because of possible | 6870 -- But that's precisely what won't work because of possible |
7078 -- unwanted optimization (and indeed the basic motivation for | 6871 -- unwanted optimization (and indeed the basic motivation for |
7079 -- the Valid attribute is exactly that this test does not work). | 6872 -- the Valid attribute is exactly that this test does not work). |
7080 -- What will work is: | 6873 -- What will work is: |
7081 | 6874 |
7082 -- Btyp!(X) >= Btyp!(type(X)'First) | 6875 -- PBtyp!(X) >= PBtyp!(type(X)'First) |
7083 -- and then | 6876 -- and then |
7084 -- Btyp!(X) <= Btyp!(type(X)'Last) | 6877 -- PBtyp!(X) <= PBtyp!(type(X)'Last) |
7085 | 6878 |
7086 -- where Btyp is an integer type large enough to cover the full | 6879 -- where PBtyp is an integer type large enough to cover the full |
7087 -- range of possible stored values (i.e. it is chosen on the basis | 6880 -- range of possible stored values (i.e. it is chosen on the basis |
7088 -- of the size of the type, not the range of the values). We write | 6881 -- of the size of the type, not the range of the values). We write |
7089 -- this as two tests, rather than a range check, so that static | 6882 -- this as two tests, rather than a range check, so that static |
7090 -- evaluation will easily remove either or both of the checks if | 6883 -- evaluation will easily remove either or both of the checks if |
7091 -- they can be -statically determined to be true (this happens | 6884 -- they can be -statically determined to be true (this happens |
7105 -- Now the base type is signed, but objects of this type are bits | 6898 -- Now the base type is signed, but objects of this type are bits |
7106 -- unsigned, and doing an unsigned test of the range 1 to 200 is | 6899 -- unsigned, and doing an unsigned test of the range 1 to 200 is |
7107 -- correct, even though a value greater than 127 looks signed to a | 6900 -- correct, even though a value greater than 127 looks signed to a |
7108 -- signed comparison. | 6901 -- signed comparison. |
7109 | 6902 |
7110 elsif Is_Unsigned_Type (Ptyp) then | 6903 elsif Is_Unsigned_Type (Ptyp) |
6904 or else (Is_Private_Type (Ptyp) and then Is_Unsigned_Type (Btyp)) | |
6905 then | |
7111 if Esize (Ptyp) <= 32 then | 6906 if Esize (Ptyp) <= 32 then |
7112 Btyp := RTE (RE_Unsigned_32); | 6907 PBtyp := RTE (RE_Unsigned_32); |
7113 else | 6908 else |
7114 Btyp := RTE (RE_Unsigned_64); | 6909 PBtyp := RTE (RE_Unsigned_64); |
7115 end if; | 6910 end if; |
7116 | 6911 |
7117 Rewrite (N, Make_Range_Test); | 6912 Rewrite (N, Make_Range_Test); |
7118 | 6913 |
7119 -- Signed types | 6914 -- Signed types |
7120 | 6915 |
7121 else | 6916 else |
7122 if Esize (Ptyp) <= Esize (Standard_Integer) then | 6917 if Esize (Ptyp) <= Esize (Standard_Integer) then |
7123 Btyp := Standard_Integer; | 6918 PBtyp := Standard_Integer; |
7124 else | 6919 else |
7125 Btyp := Universal_Integer; | 6920 PBtyp := Universal_Integer; |
7126 end if; | 6921 end if; |
7127 | 6922 |
7128 Rewrite (N, Make_Range_Test); | 6923 Rewrite (N, Make_Range_Test); |
7129 end if; | 6924 end if; |
7130 | 6925 |
7701 Attribute_Name => Cnam)), | 7496 Attribute_Name => Cnam)), |
7702 Reason => CE_Overflow_Check_Failed)); | 7497 Reason => CE_Overflow_Check_Failed)); |
7703 end if; | 7498 end if; |
7704 end Expand_Pred_Succ_Attribute; | 7499 end Expand_Pred_Succ_Attribute; |
7705 | 7500 |
7501 --------------------------- | |
7502 -- Expand_Size_Attribute -- | |
7503 --------------------------- | |
7504 | |
7505 procedure Expand_Size_Attribute (N : Node_Id) is | |
7506 Loc : constant Source_Ptr := Sloc (N); | |
7507 Typ : constant Entity_Id := Etype (N); | |
7508 Pref : constant Node_Id := Prefix (N); | |
7509 Ptyp : constant Entity_Id := Etype (Pref); | |
7510 Id : constant Attribute_Id := Get_Attribute_Id (Attribute_Name (N)); | |
7511 Siz : Uint; | |
7512 | |
7513 begin | |
7514 -- Case of known RM_Size of a type | |
7515 | |
7516 if (Id = Attribute_Size or else Id = Attribute_Value_Size) | |
7517 and then Is_Entity_Name (Pref) | |
7518 and then Is_Type (Entity (Pref)) | |
7519 and then Known_Static_RM_Size (Entity (Pref)) | |
7520 then | |
7521 Siz := RM_Size (Entity (Pref)); | |
7522 | |
7523 -- Case of known Esize of a type | |
7524 | |
7525 elsif Id = Attribute_Object_Size | |
7526 and then Is_Entity_Name (Pref) | |
7527 and then Is_Type (Entity (Pref)) | |
7528 and then Known_Static_Esize (Entity (Pref)) | |
7529 then | |
7530 Siz := Esize (Entity (Pref)); | |
7531 | |
7532 -- Case of known size of object | |
7533 | |
7534 elsif Id = Attribute_Size | |
7535 and then Is_Entity_Name (Pref) | |
7536 and then Is_Object (Entity (Pref)) | |
7537 and then Known_Esize (Entity (Pref)) | |
7538 and then Known_Static_Esize (Entity (Pref)) | |
7539 then | |
7540 Siz := Esize (Entity (Pref)); | |
7541 | |
7542 -- For an array component, we can do Size in the front end if the | |
7543 -- component_size of the array is set. | |
7544 | |
7545 elsif Nkind (Pref) = N_Indexed_Component then | |
7546 Siz := Component_Size (Etype (Prefix (Pref))); | |
7547 | |
7548 -- For a record component, we can do Size in the front end if there is a | |
7549 -- component clause, or if the record is packed and the component's size | |
7550 -- is known at compile time. | |
7551 | |
7552 elsif Nkind (Pref) = N_Selected_Component then | |
7553 declare | |
7554 Rec : constant Entity_Id := Etype (Prefix (Pref)); | |
7555 Comp : constant Entity_Id := Entity (Selector_Name (Pref)); | |
7556 | |
7557 begin | |
7558 if Present (Component_Clause (Comp)) then | |
7559 Siz := Esize (Comp); | |
7560 | |
7561 elsif Is_Packed (Rec) then | |
7562 Siz := RM_Size (Ptyp); | |
7563 | |
7564 else | |
7565 Apply_Universal_Integer_Attribute_Checks (N); | |
7566 return; | |
7567 end if; | |
7568 end; | |
7569 | |
7570 -- All other cases are handled by the back end | |
7571 | |
7572 else | |
7573 -- If Size is applied to a formal parameter that is of a packed | |
7574 -- array subtype, then apply Size to the actual subtype. | |
7575 | |
7576 if Is_Entity_Name (Pref) | |
7577 and then Is_Formal (Entity (Pref)) | |
7578 and then Is_Array_Type (Ptyp) | |
7579 and then Is_Packed (Ptyp) | |
7580 then | |
7581 Rewrite (N, | |
7582 Make_Attribute_Reference (Loc, | |
7583 Prefix => | |
7584 New_Occurrence_Of (Get_Actual_Subtype (Pref), Loc), | |
7585 Attribute_Name => Name_Size)); | |
7586 Analyze_And_Resolve (N, Typ); | |
7587 | |
7588 -- If Size is applied to a dereference of an access to unconstrained | |
7589 -- packed array, the back end needs to see its unconstrained nominal | |
7590 -- type, but also a hint to the actual constrained type. | |
7591 | |
7592 elsif Nkind (Pref) = N_Explicit_Dereference | |
7593 and then Is_Array_Type (Ptyp) | |
7594 and then not Is_Constrained (Ptyp) | |
7595 and then Is_Packed (Ptyp) | |
7596 then | |
7597 Set_Actual_Designated_Subtype (Pref, Get_Actual_Subtype (Pref)); | |
7598 | |
7599 -- If Size was applied to a slice of a bit-packed array, we rewrite | |
7600 -- it into the product of Length and Component_Size. We need to do so | |
7601 -- because bit-packed arrays are represented internally as arrays of | |
7602 -- System.Unsigned_Types.Packed_Byte for code generation purposes so | |
7603 -- the size is always rounded up in the back end. | |
7604 | |
7605 elsif Nkind (Pref) = N_Slice and then Is_Bit_Packed_Array (Ptyp) then | |
7606 Rewrite (N, | |
7607 Make_Op_Multiply (Loc, | |
7608 Make_Attribute_Reference (Loc, | |
7609 Prefix => Duplicate_Subexpr (Pref, True), | |
7610 Attribute_Name => Name_Length), | |
7611 Make_Attribute_Reference (Loc, | |
7612 Prefix => Duplicate_Subexpr (Pref, True), | |
7613 Attribute_Name => Name_Component_Size))); | |
7614 Analyze_And_Resolve (N, Typ); | |
7615 end if; | |
7616 | |
7617 -- Apply the required checks last, after rewriting has taken place | |
7618 | |
7619 Apply_Universal_Integer_Attribute_Checks (N); | |
7620 return; | |
7621 end if; | |
7622 | |
7623 -- Common processing for record and array component case | |
7624 | |
7625 if Siz /= No_Uint and then Siz /= 0 then | |
7626 declare | |
7627 CS : constant Boolean := Comes_From_Source (N); | |
7628 | |
7629 begin | |
7630 Rewrite (N, Make_Integer_Literal (Loc, Siz)); | |
7631 | |
7632 -- This integer literal is not a static expression. We do not | |
7633 -- call Analyze_And_Resolve here, because this would activate | |
7634 -- the circuit for deciding that a static value was out of range, | |
7635 -- and we don't want that. | |
7636 | |
7637 -- So just manually set the type, mark the expression as | |
7638 -- nonstatic, and then ensure that the result is checked | |
7639 -- properly if the attribute comes from source (if it was | |
7640 -- internally generated, we never need a constraint check). | |
7641 | |
7642 Set_Etype (N, Typ); | |
7643 Set_Is_Static_Expression (N, False); | |
7644 | |
7645 if CS then | |
7646 Apply_Constraint_Check (N, Typ); | |
7647 end if; | |
7648 end; | |
7649 end if; | |
7650 end Expand_Size_Attribute; | |
7651 | |
7706 ----------------------------- | 7652 ----------------------------- |
7707 -- Expand_Update_Attribute -- | 7653 -- Expand_Update_Attribute -- |
7708 ----------------------------- | 7654 ----------------------------- |
7709 | 7655 |
7710 procedure Expand_Update_Attribute (N : Node_Id) is | 7656 procedure Expand_Update_Attribute (N : Node_Id) is |
7985 (Typ : Entity_Id; | 7931 (Typ : Entity_Id; |
7986 Nam : TSS_Name_Type) return Entity_Id | 7932 Nam : TSS_Name_Type) return Entity_Id |
7987 is | 7933 is |
7988 Base_Typ : constant Entity_Id := Base_Type (Typ); | 7934 Base_Typ : constant Entity_Id := Base_Type (Typ); |
7989 Ent : constant Entity_Id := TSS (Typ, Nam); | 7935 Ent : constant Entity_Id := TSS (Typ, Nam); |
7990 | |
7991 function Is_Available (Entity : RE_Id) return Boolean; | |
7992 pragma Inline (Is_Available); | |
7993 -- Function to check whether the specified run-time call is available | |
7994 -- in the run time used. In the case of a configurable run time, it | |
7995 -- is normal that some subprograms are not there. | |
7996 -- | |
7997 -- I don't understand this routine at all, why is this not just a | |
7998 -- call to RTE_Available? And if for some reason we need a different | |
7999 -- routine with different semantics, why is not in Rtsfind ??? | |
8000 | |
8001 ------------------ | |
8002 -- Is_Available -- | |
8003 ------------------ | |
8004 | |
8005 function Is_Available (Entity : RE_Id) return Boolean is | |
8006 begin | |
8007 -- Assume that the unit will always be available when using a | |
8008 -- "normal" (not configurable) run time. | |
8009 | |
8010 return not Configurable_Run_Time_Mode or else RTE_Available (Entity); | |
8011 end Is_Available; | |
8012 | |
8013 -- Start of processing for Find_Stream_Subprogram | |
8014 | |
8015 begin | 7936 begin |
8016 if Present (Ent) then | 7937 if Present (Ent) then |
8017 return Ent; | 7938 return Ent; |
8018 end if; | 7939 end if; |
8019 | 7940 |
8026 | 7947 |
8027 -- Note: In the case of using a configurable run time, it is very likely | 7948 -- Note: In the case of using a configurable run time, it is very likely |
8028 -- that stream routines for string types are not present (they require | 7949 -- that stream routines for string types are not present (they require |
8029 -- file system support). In this case, the specific stream routines for | 7950 -- file system support). In this case, the specific stream routines for |
8030 -- strings are not used, relying on the regular stream mechanism | 7951 -- strings are not used, relying on the regular stream mechanism |
8031 -- instead. That is why we include the test Is_Available when dealing | 7952 -- instead. That is why we include the test RTE_Available when dealing |
8032 -- with these cases. | 7953 -- with these cases. |
8033 | 7954 |
8034 if not Is_Predefined_Unit (Current_Sem_Unit) then | 7955 if not Is_Predefined_Unit (Current_Sem_Unit) then |
8035 -- Storage_Array as defined in package System.Storage_Elements | 7956 -- Storage_Array as defined in package System.Storage_Elements |
8036 | 7957 |
8038 | 7959 |
8039 -- Case of No_Stream_Optimizations restriction active | 7960 -- Case of No_Stream_Optimizations restriction active |
8040 | 7961 |
8041 if Restriction_Active (No_Stream_Optimizations) then | 7962 if Restriction_Active (No_Stream_Optimizations) then |
8042 if Nam = TSS_Stream_Input | 7963 if Nam = TSS_Stream_Input |
8043 and then Is_Available (RE_Storage_Array_Input) | 7964 and then RTE_Available (RE_Storage_Array_Input) |
8044 then | 7965 then |
8045 return RTE (RE_Storage_Array_Input); | 7966 return RTE (RE_Storage_Array_Input); |
8046 | 7967 |
8047 elsif Nam = TSS_Stream_Output | 7968 elsif Nam = TSS_Stream_Output |
8048 and then Is_Available (RE_Storage_Array_Output) | 7969 and then RTE_Available (RE_Storage_Array_Output) |
8049 then | 7970 then |
8050 return RTE (RE_Storage_Array_Output); | 7971 return RTE (RE_Storage_Array_Output); |
8051 | 7972 |
8052 elsif Nam = TSS_Stream_Read | 7973 elsif Nam = TSS_Stream_Read |
8053 and then Is_Available (RE_Storage_Array_Read) | 7974 and then RTE_Available (RE_Storage_Array_Read) |
8054 then | 7975 then |
8055 return RTE (RE_Storage_Array_Read); | 7976 return RTE (RE_Storage_Array_Read); |
8056 | 7977 |
8057 elsif Nam = TSS_Stream_Write | 7978 elsif Nam = TSS_Stream_Write |
8058 and then Is_Available (RE_Storage_Array_Write) | 7979 and then RTE_Available (RE_Storage_Array_Write) |
8059 then | 7980 then |
8060 return RTE (RE_Storage_Array_Write); | 7981 return RTE (RE_Storage_Array_Write); |
8061 | 7982 |
8062 elsif Nam /= TSS_Stream_Input and then | 7983 elsif Nam /= TSS_Stream_Input and then |
8063 Nam /= TSS_Stream_Output and then | 7984 Nam /= TSS_Stream_Output and then |
8070 -- Restriction No_Stream_Optimizations is not set, so we can go | 7991 -- Restriction No_Stream_Optimizations is not set, so we can go |
8071 -- ahead and optimize using the block IO forms of the routines. | 7992 -- ahead and optimize using the block IO forms of the routines. |
8072 | 7993 |
8073 else | 7994 else |
8074 if Nam = TSS_Stream_Input | 7995 if Nam = TSS_Stream_Input |
8075 and then Is_Available (RE_Storage_Array_Input_Blk_IO) | 7996 and then RTE_Available (RE_Storage_Array_Input_Blk_IO) |
8076 then | 7997 then |
8077 return RTE (RE_Storage_Array_Input_Blk_IO); | 7998 return RTE (RE_Storage_Array_Input_Blk_IO); |
8078 | 7999 |
8079 elsif Nam = TSS_Stream_Output | 8000 elsif Nam = TSS_Stream_Output |
8080 and then Is_Available (RE_Storage_Array_Output_Blk_IO) | 8001 and then RTE_Available (RE_Storage_Array_Output_Blk_IO) |
8081 then | 8002 then |
8082 return RTE (RE_Storage_Array_Output_Blk_IO); | 8003 return RTE (RE_Storage_Array_Output_Blk_IO); |
8083 | 8004 |
8084 elsif Nam = TSS_Stream_Read | 8005 elsif Nam = TSS_Stream_Read |
8085 and then Is_Available (RE_Storage_Array_Read_Blk_IO) | 8006 and then RTE_Available (RE_Storage_Array_Read_Blk_IO) |
8086 then | 8007 then |
8087 return RTE (RE_Storage_Array_Read_Blk_IO); | 8008 return RTE (RE_Storage_Array_Read_Blk_IO); |
8088 | 8009 |
8089 elsif Nam = TSS_Stream_Write | 8010 elsif Nam = TSS_Stream_Write |
8090 and then Is_Available (RE_Storage_Array_Write_Blk_IO) | 8011 and then RTE_Available (RE_Storage_Array_Write_Blk_IO) |
8091 then | 8012 then |
8092 return RTE (RE_Storage_Array_Write_Blk_IO); | 8013 return RTE (RE_Storage_Array_Write_Blk_IO); |
8093 | 8014 |
8094 elsif Nam /= TSS_Stream_Input and then | 8015 elsif Nam /= TSS_Stream_Input and then |
8095 Nam /= TSS_Stream_Output and then | 8016 Nam /= TSS_Stream_Output and then |
8106 | 8027 |
8107 -- Case of No_Stream_Optimizations restriction active | 8028 -- Case of No_Stream_Optimizations restriction active |
8108 | 8029 |
8109 if Restriction_Active (No_Stream_Optimizations) then | 8030 if Restriction_Active (No_Stream_Optimizations) then |
8110 if Nam = TSS_Stream_Input | 8031 if Nam = TSS_Stream_Input |
8111 and then Is_Available (RE_Stream_Element_Array_Input) | 8032 and then RTE_Available (RE_Stream_Element_Array_Input) |
8112 then | 8033 then |
8113 return RTE (RE_Stream_Element_Array_Input); | 8034 return RTE (RE_Stream_Element_Array_Input); |
8114 | 8035 |
8115 elsif Nam = TSS_Stream_Output | 8036 elsif Nam = TSS_Stream_Output |
8116 and then Is_Available (RE_Stream_Element_Array_Output) | 8037 and then RTE_Available (RE_Stream_Element_Array_Output) |
8117 then | 8038 then |
8118 return RTE (RE_Stream_Element_Array_Output); | 8039 return RTE (RE_Stream_Element_Array_Output); |
8119 | 8040 |
8120 elsif Nam = TSS_Stream_Read | 8041 elsif Nam = TSS_Stream_Read |
8121 and then Is_Available (RE_Stream_Element_Array_Read) | 8042 and then RTE_Available (RE_Stream_Element_Array_Read) |
8122 then | 8043 then |
8123 return RTE (RE_Stream_Element_Array_Read); | 8044 return RTE (RE_Stream_Element_Array_Read); |
8124 | 8045 |
8125 elsif Nam = TSS_Stream_Write | 8046 elsif Nam = TSS_Stream_Write |
8126 and then Is_Available (RE_Stream_Element_Array_Write) | 8047 and then RTE_Available (RE_Stream_Element_Array_Write) |
8127 then | 8048 then |
8128 return RTE (RE_Stream_Element_Array_Write); | 8049 return RTE (RE_Stream_Element_Array_Write); |
8129 | 8050 |
8130 elsif Nam /= TSS_Stream_Input and then | 8051 elsif Nam /= TSS_Stream_Input and then |
8131 Nam /= TSS_Stream_Output and then | 8052 Nam /= TSS_Stream_Output and then |
8138 -- Restriction No_Stream_Optimizations is not set, so we can go | 8059 -- Restriction No_Stream_Optimizations is not set, so we can go |
8139 -- ahead and optimize using the block IO forms of the routines. | 8060 -- ahead and optimize using the block IO forms of the routines. |
8140 | 8061 |
8141 else | 8062 else |
8142 if Nam = TSS_Stream_Input | 8063 if Nam = TSS_Stream_Input |
8143 and then Is_Available (RE_Stream_Element_Array_Input_Blk_IO) | 8064 and then RTE_Available (RE_Stream_Element_Array_Input_Blk_IO) |
8144 then | 8065 then |
8145 return RTE (RE_Stream_Element_Array_Input_Blk_IO); | 8066 return RTE (RE_Stream_Element_Array_Input_Blk_IO); |
8146 | 8067 |
8147 elsif Nam = TSS_Stream_Output | 8068 elsif Nam = TSS_Stream_Output |
8148 and then Is_Available (RE_Stream_Element_Array_Output_Blk_IO) | 8069 and then RTE_Available (RE_Stream_Element_Array_Output_Blk_IO) |
8149 then | 8070 then |
8150 return RTE (RE_Stream_Element_Array_Output_Blk_IO); | 8071 return RTE (RE_Stream_Element_Array_Output_Blk_IO); |
8151 | 8072 |
8152 elsif Nam = TSS_Stream_Read | 8073 elsif Nam = TSS_Stream_Read |
8153 and then Is_Available (RE_Stream_Element_Array_Read_Blk_IO) | 8074 and then RTE_Available (RE_Stream_Element_Array_Read_Blk_IO) |
8154 then | 8075 then |
8155 return RTE (RE_Stream_Element_Array_Read_Blk_IO); | 8076 return RTE (RE_Stream_Element_Array_Read_Blk_IO); |
8156 | 8077 |
8157 elsif Nam = TSS_Stream_Write | 8078 elsif Nam = TSS_Stream_Write |
8158 and then Is_Available (RE_Stream_Element_Array_Write_Blk_IO) | 8079 and then RTE_Available (RE_Stream_Element_Array_Write_Blk_IO) |
8159 then | 8080 then |
8160 return RTE (RE_Stream_Element_Array_Write_Blk_IO); | 8081 return RTE (RE_Stream_Element_Array_Write_Blk_IO); |
8161 | 8082 |
8162 elsif Nam /= TSS_Stream_Input and then | 8083 elsif Nam /= TSS_Stream_Input and then |
8163 Nam /= TSS_Stream_Output and then | 8084 Nam /= TSS_Stream_Output and then |
8174 | 8095 |
8175 -- Case of No_Stream_Optimizations restriction active | 8096 -- Case of No_Stream_Optimizations restriction active |
8176 | 8097 |
8177 if Restriction_Active (No_Stream_Optimizations) then | 8098 if Restriction_Active (No_Stream_Optimizations) then |
8178 if Nam = TSS_Stream_Input | 8099 if Nam = TSS_Stream_Input |
8179 and then Is_Available (RE_String_Input) | 8100 and then RTE_Available (RE_String_Input) |
8180 then | 8101 then |
8181 return RTE (RE_String_Input); | 8102 return RTE (RE_String_Input); |
8182 | 8103 |
8183 elsif Nam = TSS_Stream_Output | 8104 elsif Nam = TSS_Stream_Output |
8184 and then Is_Available (RE_String_Output) | 8105 and then RTE_Available (RE_String_Output) |
8185 then | 8106 then |
8186 return RTE (RE_String_Output); | 8107 return RTE (RE_String_Output); |
8187 | 8108 |
8188 elsif Nam = TSS_Stream_Read | 8109 elsif Nam = TSS_Stream_Read |
8189 and then Is_Available (RE_String_Read) | 8110 and then RTE_Available (RE_String_Read) |
8190 then | 8111 then |
8191 return RTE (RE_String_Read); | 8112 return RTE (RE_String_Read); |
8192 | 8113 |
8193 elsif Nam = TSS_Stream_Write | 8114 elsif Nam = TSS_Stream_Write |
8194 and then Is_Available (RE_String_Write) | 8115 and then RTE_Available (RE_String_Write) |
8195 then | 8116 then |
8196 return RTE (RE_String_Write); | 8117 return RTE (RE_String_Write); |
8197 | 8118 |
8198 elsif Nam /= TSS_Stream_Input and then | 8119 elsif Nam /= TSS_Stream_Input and then |
8199 Nam /= TSS_Stream_Output and then | 8120 Nam /= TSS_Stream_Output and then |
8206 -- Restriction No_Stream_Optimizations is not set, so we can go | 8127 -- Restriction No_Stream_Optimizations is not set, so we can go |
8207 -- ahead and optimize using the block IO forms of the routines. | 8128 -- ahead and optimize using the block IO forms of the routines. |
8208 | 8129 |
8209 else | 8130 else |
8210 if Nam = TSS_Stream_Input | 8131 if Nam = TSS_Stream_Input |
8211 and then Is_Available (RE_String_Input_Blk_IO) | 8132 and then RTE_Available (RE_String_Input_Blk_IO) |
8212 then | 8133 then |
8213 return RTE (RE_String_Input_Blk_IO); | 8134 return RTE (RE_String_Input_Blk_IO); |
8214 | 8135 |
8215 elsif Nam = TSS_Stream_Output | 8136 elsif Nam = TSS_Stream_Output |
8216 and then Is_Available (RE_String_Output_Blk_IO) | 8137 and then RTE_Available (RE_String_Output_Blk_IO) |
8217 then | 8138 then |
8218 return RTE (RE_String_Output_Blk_IO); | 8139 return RTE (RE_String_Output_Blk_IO); |
8219 | 8140 |
8220 elsif Nam = TSS_Stream_Read | 8141 elsif Nam = TSS_Stream_Read |
8221 and then Is_Available (RE_String_Read_Blk_IO) | 8142 and then RTE_Available (RE_String_Read_Blk_IO) |
8222 then | 8143 then |
8223 return RTE (RE_String_Read_Blk_IO); | 8144 return RTE (RE_String_Read_Blk_IO); |
8224 | 8145 |
8225 elsif Nam = TSS_Stream_Write | 8146 elsif Nam = TSS_Stream_Write |
8226 and then Is_Available (RE_String_Write_Blk_IO) | 8147 and then RTE_Available (RE_String_Write_Blk_IO) |
8227 then | 8148 then |
8228 return RTE (RE_String_Write_Blk_IO); | 8149 return RTE (RE_String_Write_Blk_IO); |
8229 | 8150 |
8230 elsif Nam /= TSS_Stream_Input and then | 8151 elsif Nam /= TSS_Stream_Input and then |
8231 Nam /= TSS_Stream_Output and then | 8152 Nam /= TSS_Stream_Output and then |
8242 | 8163 |
8243 -- Case of No_Stream_Optimizations restriction active | 8164 -- Case of No_Stream_Optimizations restriction active |
8244 | 8165 |
8245 if Restriction_Active (No_Stream_Optimizations) then | 8166 if Restriction_Active (No_Stream_Optimizations) then |
8246 if Nam = TSS_Stream_Input | 8167 if Nam = TSS_Stream_Input |
8247 and then Is_Available (RE_Wide_String_Input) | 8168 and then RTE_Available (RE_Wide_String_Input) |
8248 then | 8169 then |
8249 return RTE (RE_Wide_String_Input); | 8170 return RTE (RE_Wide_String_Input); |
8250 | 8171 |
8251 elsif Nam = TSS_Stream_Output | 8172 elsif Nam = TSS_Stream_Output |
8252 and then Is_Available (RE_Wide_String_Output) | 8173 and then RTE_Available (RE_Wide_String_Output) |
8253 then | 8174 then |
8254 return RTE (RE_Wide_String_Output); | 8175 return RTE (RE_Wide_String_Output); |
8255 | 8176 |
8256 elsif Nam = TSS_Stream_Read | 8177 elsif Nam = TSS_Stream_Read |
8257 and then Is_Available (RE_Wide_String_Read) | 8178 and then RTE_Available (RE_Wide_String_Read) |
8258 then | 8179 then |
8259 return RTE (RE_Wide_String_Read); | 8180 return RTE (RE_Wide_String_Read); |
8260 | 8181 |
8261 elsif Nam = TSS_Stream_Write | 8182 elsif Nam = TSS_Stream_Write |
8262 and then Is_Available (RE_Wide_String_Write) | 8183 and then RTE_Available (RE_Wide_String_Write) |
8263 then | 8184 then |
8264 return RTE (RE_Wide_String_Write); | 8185 return RTE (RE_Wide_String_Write); |
8265 | 8186 |
8266 elsif Nam /= TSS_Stream_Input and then | 8187 elsif Nam /= TSS_Stream_Input and then |
8267 Nam /= TSS_Stream_Output and then | 8188 Nam /= TSS_Stream_Output and then |
8274 -- Restriction No_Stream_Optimizations is not set, so we can go | 8195 -- Restriction No_Stream_Optimizations is not set, so we can go |
8275 -- ahead and optimize using the block IO forms of the routines. | 8196 -- ahead and optimize using the block IO forms of the routines. |
8276 | 8197 |
8277 else | 8198 else |
8278 if Nam = TSS_Stream_Input | 8199 if Nam = TSS_Stream_Input |
8279 and then Is_Available (RE_Wide_String_Input_Blk_IO) | 8200 and then RTE_Available (RE_Wide_String_Input_Blk_IO) |
8280 then | 8201 then |
8281 return RTE (RE_Wide_String_Input_Blk_IO); | 8202 return RTE (RE_Wide_String_Input_Blk_IO); |
8282 | 8203 |
8283 elsif Nam = TSS_Stream_Output | 8204 elsif Nam = TSS_Stream_Output |
8284 and then Is_Available (RE_Wide_String_Output_Blk_IO) | 8205 and then RTE_Available (RE_Wide_String_Output_Blk_IO) |
8285 then | 8206 then |
8286 return RTE (RE_Wide_String_Output_Blk_IO); | 8207 return RTE (RE_Wide_String_Output_Blk_IO); |
8287 | 8208 |
8288 elsif Nam = TSS_Stream_Read | 8209 elsif Nam = TSS_Stream_Read |
8289 and then Is_Available (RE_Wide_String_Read_Blk_IO) | 8210 and then RTE_Available (RE_Wide_String_Read_Blk_IO) |
8290 then | 8211 then |
8291 return RTE (RE_Wide_String_Read_Blk_IO); | 8212 return RTE (RE_Wide_String_Read_Blk_IO); |
8292 | 8213 |
8293 elsif Nam = TSS_Stream_Write | 8214 elsif Nam = TSS_Stream_Write |
8294 and then Is_Available (RE_Wide_String_Write_Blk_IO) | 8215 and then RTE_Available (RE_Wide_String_Write_Blk_IO) |
8295 then | 8216 then |
8296 return RTE (RE_Wide_String_Write_Blk_IO); | 8217 return RTE (RE_Wide_String_Write_Blk_IO); |
8297 | 8218 |
8298 elsif Nam /= TSS_Stream_Input and then | 8219 elsif Nam /= TSS_Stream_Input and then |
8299 Nam /= TSS_Stream_Output and then | 8220 Nam /= TSS_Stream_Output and then |
8310 | 8231 |
8311 -- Case of No_Stream_Optimizations restriction active | 8232 -- Case of No_Stream_Optimizations restriction active |
8312 | 8233 |
8313 if Restriction_Active (No_Stream_Optimizations) then | 8234 if Restriction_Active (No_Stream_Optimizations) then |
8314 if Nam = TSS_Stream_Input | 8235 if Nam = TSS_Stream_Input |
8315 and then Is_Available (RE_Wide_Wide_String_Input) | 8236 and then RTE_Available (RE_Wide_Wide_String_Input) |
8316 then | 8237 then |
8317 return RTE (RE_Wide_Wide_String_Input); | 8238 return RTE (RE_Wide_Wide_String_Input); |
8318 | 8239 |
8319 elsif Nam = TSS_Stream_Output | 8240 elsif Nam = TSS_Stream_Output |
8320 and then Is_Available (RE_Wide_Wide_String_Output) | 8241 and then RTE_Available (RE_Wide_Wide_String_Output) |
8321 then | 8242 then |
8322 return RTE (RE_Wide_Wide_String_Output); | 8243 return RTE (RE_Wide_Wide_String_Output); |
8323 | 8244 |
8324 elsif Nam = TSS_Stream_Read | 8245 elsif Nam = TSS_Stream_Read |
8325 and then Is_Available (RE_Wide_Wide_String_Read) | 8246 and then RTE_Available (RE_Wide_Wide_String_Read) |
8326 then | 8247 then |
8327 return RTE (RE_Wide_Wide_String_Read); | 8248 return RTE (RE_Wide_Wide_String_Read); |
8328 | 8249 |
8329 elsif Nam = TSS_Stream_Write | 8250 elsif Nam = TSS_Stream_Write |
8330 and then Is_Available (RE_Wide_Wide_String_Write) | 8251 and then RTE_Available (RE_Wide_Wide_String_Write) |
8331 then | 8252 then |
8332 return RTE (RE_Wide_Wide_String_Write); | 8253 return RTE (RE_Wide_Wide_String_Write); |
8333 | 8254 |
8334 elsif Nam /= TSS_Stream_Input and then | 8255 elsif Nam /= TSS_Stream_Input and then |
8335 Nam /= TSS_Stream_Output and then | 8256 Nam /= TSS_Stream_Output and then |
8342 -- Restriction No_Stream_Optimizations is not set, so we can go | 8263 -- Restriction No_Stream_Optimizations is not set, so we can go |
8343 -- ahead and optimize using the block IO forms of the routines. | 8264 -- ahead and optimize using the block IO forms of the routines. |
8344 | 8265 |
8345 else | 8266 else |
8346 if Nam = TSS_Stream_Input | 8267 if Nam = TSS_Stream_Input |
8347 and then Is_Available (RE_Wide_Wide_String_Input_Blk_IO) | 8268 and then RTE_Available (RE_Wide_Wide_String_Input_Blk_IO) |
8348 then | 8269 then |
8349 return RTE (RE_Wide_Wide_String_Input_Blk_IO); | 8270 return RTE (RE_Wide_Wide_String_Input_Blk_IO); |
8350 | 8271 |
8351 elsif Nam = TSS_Stream_Output | 8272 elsif Nam = TSS_Stream_Output |
8352 and then Is_Available (RE_Wide_Wide_String_Output_Blk_IO) | 8273 and then RTE_Available (RE_Wide_Wide_String_Output_Blk_IO) |
8353 then | 8274 then |
8354 return RTE (RE_Wide_Wide_String_Output_Blk_IO); | 8275 return RTE (RE_Wide_Wide_String_Output_Blk_IO); |
8355 | 8276 |
8356 elsif Nam = TSS_Stream_Read | 8277 elsif Nam = TSS_Stream_Read |
8357 and then Is_Available (RE_Wide_Wide_String_Read_Blk_IO) | 8278 and then RTE_Available (RE_Wide_Wide_String_Read_Blk_IO) |
8358 then | 8279 then |
8359 return RTE (RE_Wide_Wide_String_Read_Blk_IO); | 8280 return RTE (RE_Wide_Wide_String_Read_Blk_IO); |
8360 | 8281 |
8361 elsif Nam = TSS_Stream_Write | 8282 elsif Nam = TSS_Stream_Write |
8362 and then Is_Available (RE_Wide_Wide_String_Write_Blk_IO) | 8283 and then RTE_Available (RE_Wide_Wide_String_Write_Blk_IO) |
8363 then | 8284 then |
8364 return RTE (RE_Wide_Wide_String_Write_Blk_IO); | 8285 return RTE (RE_Wide_Wide_String_Write_Blk_IO); |
8365 | 8286 |
8366 elsif Nam /= TSS_Stream_Input and then | 8287 elsif Nam /= TSS_Stream_Input and then |
8367 Nam /= TSS_Stream_Output and then | 8288 Nam /= TSS_Stream_Output and then |
8523 or else not Is_Integer_Type (Etype (Parent (N))) | 8444 or else not Is_Integer_Type (Etype (Parent (N))) |
8524 then | 8445 then |
8525 return False; | 8446 return False; |
8526 end if; | 8447 end if; |
8527 | 8448 |
8528 -- Here we are in the integer conversion context | 8449 -- Here we are in the integer conversion context. We reuse Rounding for |
8529 | 8450 -- Machine_Rounding as System.Fat_Gen, which is a permissible behavior. |
8530 -- Very probably we should also recognize the cases of Machine_Rounding | 8451 |
8531 -- and unbiased rounding in this conversion context, but the back end is | 8452 return |
8532 -- not yet prepared to handle these cases ??? | 8453 Id = Attribute_Rounding |
8533 | 8454 or else Id = Attribute_Machine_Rounding |
8534 return Id = Attribute_Rounding or else Id = Attribute_Truncation; | 8455 or else Id = Attribute_Truncation; |
8535 end Is_Inline_Floating_Point_Attribute; | 8456 end Is_Inline_Floating_Point_Attribute; |
8536 | 8457 |
8537 end Exp_Attr; | 8458 end Exp_Attr; |