comparison gcc/ada/sem_ch7.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 -- S E M _ C H 7 -- 5 -- S E M _ C H 7 --
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- --
387 if Is_Generic_Unit (Decl_Id) then 387 if Is_Generic_Unit (Decl_Id) then
388 return True; 388 return True;
389 end if; 389 end if;
390 390
391 -- An inlined subprogram body acts as a referencer 391 -- An inlined subprogram body acts as a referencer
392 -- unless we generate C code since inlining is then
393 -- handled by the C compiler.
392 394
393 -- Note that we test Has_Pragma_Inline here in addition 395 -- Note that we test Has_Pragma_Inline here in addition
394 -- to Is_Inlined. We are doing this for a client, since 396 -- to Is_Inlined. We are doing this for a client, since
395 -- we are computing which entities should be public, and 397 -- we are computing which entities should be public, and
396 -- it is the client who will decide if actual inlining 398 -- it is the client who will decide if actual inlining
397 -- should occur, so we need to catch all cases where the 399 -- should occur, so we need to catch all cases where the
398 -- subprogram may be inlined by the client. 400 -- subprogram may be inlined by the client.
399 401
400 if Is_Inlined (Decl_Id) 402 if not Generate_C_Code
401 or else Has_Pragma_Inline (Decl_Id) 403 and then (Is_Inlined (Decl_Id)
404 or else Has_Pragma_Inline (Decl_Id))
402 then 405 then
403 Has_Referencer_Of_Non_Subprograms := True; 406 Has_Referencer_Of_Non_Subprograms := True;
404 407
405 -- Inspect the statements of the subprogram body 408 -- Inspect the statements of the subprogram body
406 -- to determine whether the body references other 409 -- to determine whether the body references other
413 416
414 else 417 else
415 Decl_Id := Defining_Entity (Decl); 418 Decl_Id := Defining_Entity (Decl);
416 419
417 -- An inlined subprogram body acts as a referencer 420 -- An inlined subprogram body acts as a referencer
418 421 -- unless we generate C code since inlining is then
419 if Is_Inlined (Decl_Id) 422 -- handled by the C compiler.
420 or else Has_Pragma_Inline (Decl_Id) 423
424 if not Generate_C_Code
425 and then (Is_Inlined (Decl_Id)
426 or else Has_Pragma_Inline (Decl_Id))
421 then 427 then
422 Has_Referencer_Of_Non_Subprograms := True; 428 Has_Referencer_Of_Non_Subprograms := True;
423 429
424 -- Inspect the statements of the subprogram body 430 -- Inspect the statements of the subprogram body
425 -- to determine whether the body references other 431 -- to determine whether the body references other
667 673
668 -- Local variables 674 -- Local variables
669 675
670 Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; 676 Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
671 Saved_IGR : constant Node_Id := Ignored_Ghost_Region; 677 Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
678 Saved_EA : constant Boolean := Expander_Active;
672 Saved_ISMP : constant Boolean := 679 Saved_ISMP : constant Boolean :=
673 Ignore_SPARK_Mode_Pragmas_In_Instance; 680 Ignore_SPARK_Mode_Pragmas_In_Instance;
674 -- Save the Ghost and SPARK mode-related data to restore on exit 681 -- Save the Ghost and SPARK mode-related data to restore on exit
675 682
676 Body_Id : Entity_Id; 683 Body_Id : Entity_Id;
778 -- the mode now to ensure that any nodes generated during analysis and 785 -- the mode now to ensure that any nodes generated during analysis and
779 -- expansion are properly flagged as ignored Ghost. 786 -- expansion are properly flagged as ignored Ghost.
780 787
781 Mark_And_Set_Ghost_Body (N, Spec_Id); 788 Mark_And_Set_Ghost_Body (N, Spec_Id);
782 789
790 -- Deactivate expansion inside the body of ignored Ghost entities,
791 -- as this code will ultimately be ignored. This avoids requiring the
792 -- presence of run-time units which are not needed. Only do this for
793 -- user entities, as internally generated entities might still need
794 -- to be expanded (e.g. those generated for types).
795
796 if Present (Ignored_Ghost_Region)
797 and then Comes_From_Source (Body_Id)
798 then
799 Expander_Active := False;
800 end if;
801
783 -- If the body completes the initial declaration of a compilation unit 802 -- If the body completes the initial declaration of a compilation unit
784 -- which is subject to pragma Elaboration_Checks, set the model of the 803 -- which is subject to pragma Elaboration_Checks, set the model of the
785 -- pragma because it applies to all parts of the unit. 804 -- pragma because it applies to all parts of the unit.
786 805
787 Install_Elaboration_Model (Spec_Id); 806 Install_Elaboration_Model (Spec_Id);
904 Set_Use (Private_Declarations (Specification (Pack_Decl))); 923 Set_Use (Private_Declarations (Specification (Pack_Decl)));
905 924
906 -- This is a nested package, so it may be necessary to declare certain 925 -- This is a nested package, so it may be necessary to declare certain
907 -- inherited subprograms that are not yet visible because the parent 926 -- inherited subprograms that are not yet visible because the parent
908 -- type's subprograms are now visible. 927 -- type's subprograms are now visible.
928 -- Note that for child units these operations were generated when
929 -- analyzing the package specification.
909 930
910 if Ekind (Scope (Spec_Id)) = E_Package 931 if Ekind (Scope (Spec_Id)) = E_Package
911 and then Scope (Spec_Id) /= Standard_Standard 932 and then Scope (Spec_Id) /= Standard_Standard
933 and then not Is_Child_Unit (Spec_Id)
912 then 934 then
913 Declare_Inherited_Private_Subprograms (Spec_Id); 935 Declare_Inherited_Private_Subprograms (Spec_Id);
914 end if; 936 end if;
915 937
916 if Present (Declarations (N)) then 938 if Present (Declarations (N)) then
1042 1064
1043 -- At this point all entities of the package body are externally visible 1065 -- At this point all entities of the package body are externally visible
1044 -- to the linker as their Is_Public flag is set to True. This proactive 1066 -- to the linker as their Is_Public flag is set to True. This proactive
1045 -- approach is necessary because an inlined or a generic body for which 1067 -- approach is necessary because an inlined or a generic body for which
1046 -- code is generated in other units may need to see these entities. Cut 1068 -- code is generated in other units may need to see these entities. Cut
1047 -- down the number of global symbols that do not neet public visibility 1069 -- down the number of global symbols that do not need public visibility
1048 -- as this has two beneficial effects: 1070 -- as this has two beneficial effects:
1049 -- (1) It makes the compilation process more efficient. 1071 -- (1) It makes the compilation process more efficient.
1050 -- (2) It gives the code generator more leeway to optimize within each 1072 -- (2) It gives the code generator more leeway to optimize within each
1051 -- unit, especially subprograms. 1073 -- unit, especially subprograms.
1052 1074
1071 if Is_Generic_Instance (Spec_Id) 1093 if Is_Generic_Instance (Spec_Id)
1072 and then Operating_Mode = Generate_Code 1094 and then Operating_Mode = Generate_Code
1073 then 1095 then
1074 Qualify_Entity_Names (N); 1096 Qualify_Entity_Names (N);
1075 end if; 1097 end if;
1098 end if;
1099
1100 if Present (Ignored_Ghost_Region) then
1101 Expander_Active := Saved_EA;
1076 end if; 1102 end if;
1077 1103
1078 Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP; 1104 Ignore_SPARK_Mode_Pragmas_In_Instance := Saved_ISMP;
1079 Restore_Ghost_Region (Saved_GM, Saved_IGR); 1105 Restore_Ghost_Region (Saved_GM, Saved_IGR);
1080 end Analyze_Package_Body_Helper; 1106 end Analyze_Package_Body_Helper;
1246 -- the chain whose first element is FE. A recursive call is made for all 1272 -- the chain whose first element is FE. A recursive call is made for all
1247 -- packages and generic packages. 1273 -- packages and generic packages.
1248 1274
1249 procedure Generate_Parent_References; 1275 procedure Generate_Parent_References;
1250 -- For a child unit, generate references to parent units, for 1276 -- For a child unit, generate references to parent units, for
1251 -- GPS navigation purposes. 1277 -- GNAT Studio navigation purposes.
1252 1278
1253 function Is_Public_Child (Child, Unit : Entity_Id) return Boolean; 1279 function Is_Public_Child (Child, Unit : Entity_Id) return Boolean;
1254 -- Child and Unit are entities of compilation units. True if Child 1280 -- Child and Unit are entities of compilation units. True if Child
1255 -- is a public child of Parent as defined in 10.1.1 1281 -- is a public child of Parent as defined in 10.1.1
1256 1282
1483 1509
1484 if Present (Renamed_Entity (Inst_Par)) then 1510 if Present (Renamed_Entity (Inst_Par)) then
1485 Inst_Par := Renamed_Entity (Inst_Par); 1511 Inst_Par := Renamed_Entity (Inst_Par);
1486 end if; 1512 end if;
1487 1513
1488 Gen_Par := 1514 -- The instance may appear in a sibling generic unit, in
1489 Generic_Parent 1515 -- which case the prefix must include the common (generic)
1490 (Specification (Unit_Declaration_Node (Inst_Par))); 1516 -- ancestor, which is treated as a current instance.
1517
1518 if Inside_A_Generic
1519 and then Ekind (Inst_Par) = E_Generic_Package
1520 then
1521 Gen_Par := Inst_Par;
1522 pragma Assert (In_Open_Scopes (Gen_Par));
1523
1524 else
1525 Gen_Par :=
1526 Generic_Parent
1527 (Specification (Unit_Declaration_Node (Inst_Par)));
1528 end if;
1491 1529
1492 -- Install the private declarations and private use clauses 1530 -- Install the private declarations and private use clauses
1493 -- of a parent instance of the child instance, unless the 1531 -- of a parent instance of the child instance, unless the
1494 -- parent instance private declarations have already been 1532 -- parent instance private declarations have already been
1495 -- installed earlier in Analyze_Package_Specification, which 1533 -- installed earlier in Analyze_Package_Specification, which
1732 else 1770 else
1733 Set_First_Private_Entity (Id, First_Entity (Id)); 1771 Set_First_Private_Entity (Id, First_Entity (Id));
1734 end if; 1772 end if;
1735 1773
1736 -- There may be inherited private subprograms that need to be declared, 1774 -- There may be inherited private subprograms that need to be declared,
1737 -- even in the absence of an explicit private part. If there are any 1775 -- even in the absence of an explicit private part. If there are any
1738 -- public declarations in the package and the package is a public child 1776 -- public declarations in the package and the package is a public child
1739 -- unit, then an implicit private part is assumed. 1777 -- unit, then an implicit private part is assumed.
1740 1778
1741 elsif Present (L) and then Public_Child then 1779 elsif Present (L) and then Public_Child then
1742 Set_In_Private_Part (Id); 1780 Set_In_Private_Part (Id);
1858 then 1896 then
1859 Unit_Requires_Body_Info (Id); 1897 Unit_Requires_Body_Info (Id);
1860 end if; 1898 end if;
1861 1899
1862 -- Nested package specs that do not require bodies are not checked for 1900 -- Nested package specs that do not require bodies are not checked for
1863 -- ineffective use clauses due to the possbility of subunits. This is 1901 -- ineffective use clauses due to the possibility of subunits. This is
1864 -- because at this stage it is impossible to tell whether there will be 1902 -- because at this stage it is impossible to tell whether there will be
1865 -- a separate body. 1903 -- a separate body.
1866 1904
1867 if not Unit_Requires_Body (Id) 1905 if not Unit_Requires_Body (Id)
1868 and then Is_Compilation_Unit (Id) 1906 and then Is_Compilation_Unit (Id)
2236 Priv_Deps : Elist_Id; 2274 Priv_Deps : Elist_Id;
2237 2275
2238 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id); 2276 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id);
2239 -- When the full view of a private type is made available, we do the 2277 -- When the full view of a private type is made available, we do the
2240 -- same for its private dependents under proper visibility conditions. 2278 -- same for its private dependents under proper visibility conditions.
2241 -- When compiling a grand-chid unit this needs to be done recursively. 2279 -- When compiling a child unit this needs to be done recursively.
2242 2280
2243 ----------------------------- 2281 -----------------------------
2244 -- Swap_Private_Dependents -- 2282 -- Swap_Private_Dependents --
2245 ----------------------------- 2283 -----------------------------
2246 2284
2247 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id) is 2285 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id) is
2286 Cunit : Entity_Id;
2248 Deps : Elist_Id; 2287 Deps : Elist_Id;
2249 Priv : Entity_Id; 2288 Priv : Entity_Id;
2250 Priv_Elmt : Elmt_Id; 2289 Priv_Elmt : Elmt_Id;
2251 Is_Priv : Boolean; 2290 Is_Priv : Boolean;
2252 2291
2260 -- installed due to a previous call. 2299 -- installed due to a previous call.
2261 2300
2262 if Present (Full_View (Priv)) and then Is_Visible_Dependent (Priv) 2301 if Present (Full_View (Priv)) and then Is_Visible_Dependent (Priv)
2263 then 2302 then
2264 if Is_Private_Type (Priv) then 2303 if Is_Private_Type (Priv) then
2304 Cunit := Cunit_Entity (Current_Sem_Unit);
2265 Deps := Private_Dependents (Priv); 2305 Deps := Private_Dependents (Priv);
2266 Is_Priv := True; 2306 Is_Priv := True;
2267 else 2307 else
2268 Is_Priv := False; 2308 Is_Priv := False;
2269 end if; 2309 end if;
2287 (Priv, In_Open_Scopes (Scope (Priv))); 2327 (Priv, In_Open_Scopes (Scope (Priv)));
2288 2328
2289 Set_Is_Potentially_Use_Visible 2329 Set_Is_Potentially_Use_Visible
2290 (Priv, Is_Potentially_Use_Visible (Node (Priv_Elmt))); 2330 (Priv, Is_Potentially_Use_Visible (Node (Priv_Elmt)));
2291 2331
2292 -- Within a child unit, recurse, except in generic child unit, 2332 -- Recurse for child units, except in generic child units,
2293 -- which (unfortunately) handle private_dependents separately. 2333 -- which unfortunately handle private_dependents separately.
2334 -- Note that the current unit may not have been analyzed,
2335 -- for example a package body, so we cannot rely solely on
2336 -- the Is_Child_Unit flag, but that's only an optimization.
2294 2337
2295 if Is_Priv 2338 if Is_Priv
2296 and then Is_Child_Unit (Cunit_Entity (Current_Sem_Unit)) 2339 and then (No (Etype (Cunit)) or else Is_Child_Unit (Cunit))
2297 and then not Is_Empty_Elmt_List (Deps) 2340 and then not Is_Empty_Elmt_List (Deps)
2298 and then not Inside_A_Generic 2341 and then not Inside_A_Generic
2299 then 2342 then
2300 Swap_Private_Dependents (Deps); 2343 Swap_Private_Dependents (Deps);
2301 end if; 2344 end if;
2676 2719
2677 procedure Uninstall_Declarations (P : Entity_Id) is 2720 procedure Uninstall_Declarations (P : Entity_Id) is
2678 Decl : constant Node_Id := Unit_Declaration_Node (P); 2721 Decl : constant Node_Id := Unit_Declaration_Node (P);
2679 Id : Entity_Id; 2722 Id : Entity_Id;
2680 Full : Entity_Id; 2723 Full : Entity_Id;
2681 Priv_Elmt : Elmt_Id;
2682 Priv_Sub : Entity_Id;
2683 2724
2684 procedure Preserve_Full_Attributes (Priv : Entity_Id; Full : Entity_Id); 2725 procedure Preserve_Full_Attributes (Priv : Entity_Id; Full : Entity_Id);
2685 -- Copy to the private declaration the attributes of the full view that 2726 -- Copy to the private declaration the attributes of the full view that
2686 -- need to be available for the partial view also. 2727 -- need to be available for the partial view also.
2728
2729 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id);
2730 -- When the full view of a private type is made unavailable, we do the
2731 -- same for its private dependents under proper visibility conditions.
2732 -- When compiling a child unit this needs to be done recursively.
2687 2733
2688 function Type_In_Use (T : Entity_Id) return Boolean; 2734 function Type_In_Use (T : Entity_Id) return Boolean;
2689 -- Check whether type or base type appear in an active use_type clause 2735 -- Check whether type or base type appear in an active use_type clause
2690 2736
2691 ------------------------------ 2737 ------------------------------
2731 (Priv, Has_Controlled_Component (Full_Base)); 2777 (Priv, Has_Controlled_Component (Full_Base));
2732 2778
2733 Propagate_Concurrent_Flags (Priv, Base_Type (Full)); 2779 Propagate_Concurrent_Flags (Priv, Base_Type (Full));
2734 end if; 2780 end if;
2735 2781
2782 -- As explained in Freeze_Entity, private types are required to point
2783 -- to the same freeze node as their corresponding full view, if any.
2784 -- But we ought not to overwrite a node already inserted in the tree.
2785
2786 pragma Assert
2787 (Serious_Errors_Detected /= 0
2788 or else No (Freeze_Node (Priv))
2789 or else No (Parent (Freeze_Node (Priv)))
2790 or else Freeze_Node (Priv) = Freeze_Node (Full));
2791
2736 Set_Freeze_Node (Priv, Freeze_Node (Full)); 2792 Set_Freeze_Node (Priv, Freeze_Node (Full));
2737 2793
2738 -- Propagate Default_Initial_Condition-related attributes from the 2794 -- Propagate Default_Initial_Condition-related attributes from the
2739 -- base type of the full view to the full view and vice versa. This 2795 -- base type of the full view to the full view and vice versa. This
2740 -- may seem strange, but is necessary depending on which type 2796 -- may seem strange, but is necessary depending on which type
2790 Set_Discriminant_Constraint (Priv, 2846 Set_Discriminant_Constraint (Priv,
2791 Discriminant_Constraint (Full)); 2847 Discriminant_Constraint (Full));
2792 end if; 2848 end if;
2793 end if; 2849 end if;
2794 end Preserve_Full_Attributes; 2850 end Preserve_Full_Attributes;
2851
2852 -----------------------------
2853 -- Swap_Private_Dependents --
2854 -----------------------------
2855
2856 procedure Swap_Private_Dependents (Priv_Deps : Elist_Id) is
2857 Cunit : Entity_Id;
2858 Deps : Elist_Id;
2859 Priv : Entity_Id;
2860 Priv_Elmt : Elmt_Id;
2861 Is_Priv : Boolean;
2862
2863 begin
2864 Priv_Elmt := First_Elmt (Priv_Deps);
2865 while Present (Priv_Elmt) loop
2866 Priv := Node (Priv_Elmt);
2867
2868 -- Before we do the swap, we verify the presence of the Full_View
2869 -- field, which may be empty due to a swap by a previous call to
2870 -- End_Package_Scope (e.g. from the freezing mechanism).
2871
2872 if Present (Full_View (Priv)) then
2873 if Is_Private_Type (Priv) then
2874 Cunit := Cunit_Entity (Current_Sem_Unit);
2875 Deps := Private_Dependents (Priv);
2876 Is_Priv := True;
2877 else
2878 Is_Priv := False;
2879 end if;
2880
2881 if Scope (Priv) = P
2882 or else not In_Open_Scopes (Scope (Priv))
2883 then
2884 Set_Is_Immediately_Visible (Priv, False);
2885 end if;
2886
2887 if Is_Visible_Dependent (Priv) then
2888 Preserve_Full_Attributes (Priv, Full_View (Priv));
2889 Replace_Elmt (Priv_Elmt, Full_View (Priv));
2890 Exchange_Declarations (Priv);
2891
2892 -- Recurse for child units, except in generic child units,
2893 -- which unfortunately handle private_dependents separately.
2894 -- Note that the current unit may not have been analyzed,
2895 -- for example a package body, so we cannot rely solely on
2896 -- the Is_Child_Unit flag, but that's only an optimization.
2897
2898 if Is_Priv
2899 and then (No (Etype (Cunit)) or else Is_Child_Unit (Cunit))
2900 and then not Is_Empty_Elmt_List (Deps)
2901 and then not Inside_A_Generic
2902 then
2903 Swap_Private_Dependents (Deps);
2904 end if;
2905 end if;
2906 end if;
2907
2908 Next_Elmt (Priv_Elmt);
2909 end loop;
2910 end Swap_Private_Dependents;
2795 2911
2796 ----------------- 2912 -----------------
2797 -- Type_In_Use -- 2913 -- Type_In_Use --
2798 ----------------- 2914 -----------------
2799 2915
2818 -- established by use clauses in the current scope. Two cases: 2934 -- established by use clauses in the current scope. Two cases:
2819 2935
2820 -- a) If the entity is an operator, it may be a primitive operator of 2936 -- a) If the entity is an operator, it may be a primitive operator of
2821 -- a type for which there is a visible use-type clause. 2937 -- a type for which there is a visible use-type clause.
2822 2938
2823 -- b) for other entities, their use-visibility is determined by a 2939 -- b) For other entities, their use-visibility is determined by a
2824 -- visible use clause for the package itself. For a generic instance, 2940 -- visible use clause for the package itself or a use-all-type clause
2941 -- applied directly to the entity's type. For a generic instance,
2825 -- the instantiation of the formals appears in the visible part, 2942 -- the instantiation of the formals appears in the visible part,
2826 -- but the formals are private and remain so. 2943 -- but the formals are private and remain so.
2827 2944
2828 if Ekind (Id) = E_Function 2945 if Ekind (Id) = E_Function
2829 and then Is_Operator_Symbol_Name (Chars (Id)) 2946 and then Is_Operator_Symbol_Name (Chars (Id))
2852 (Id, Is_Visible_Lib_Unit (Id)); 2969 (Id, Is_Visible_Lib_Unit (Id));
2853 else 2970 else
2854 Set_Is_Potentially_Use_Visible (Id); 2971 Set_Is_Potentially_Use_Visible (Id);
2855 end if; 2972 end if;
2856 2973
2974 -- We need to avoid incorrectly marking enumeration literals as
2975 -- non-visible when a visible use-all-type clause is in effect.
2976
2977 elsif Type_In_Use (Etype (Id))
2978 and then Nkind (Current_Use_Clause (Etype (Id))) =
2979 N_Use_Type_Clause
2980 and then All_Present (Current_Use_Clause (Etype (Id)))
2981 then
2982 null;
2983
2857 else 2984 else
2858 Set_Is_Potentially_Use_Visible (Id, False); 2985 Set_Is_Potentially_Use_Visible (Id, False);
2859 end if; 2986 end if;
2860 end if; 2987 end if;
2861 2988
3031 3158
3032 -- Swap out the subtypes and derived types of Id that 3159 -- Swap out the subtypes and derived types of Id that
3033 -- were compiled in this scope, or installed previously 3160 -- were compiled in this scope, or installed previously
3034 -- by Install_Private_Declarations. 3161 -- by Install_Private_Declarations.
3035 3162
3036 -- Before we do the swap, we verify the presence of the Full_View 3163 Swap_Private_Dependents (Private_Dependents (Id));
3037 -- field which may be empty due to a swap by a previous call to
3038 -- End_Package_Scope (e.g. from the freezing mechanism).
3039
3040 Priv_Elmt := First_Elmt (Private_Dependents (Id));
3041 while Present (Priv_Elmt) loop
3042 Priv_Sub := Node (Priv_Elmt);
3043
3044 if Present (Full_View (Priv_Sub)) then
3045 if Scope (Priv_Sub) = P
3046 or else not In_Open_Scopes (Scope (Priv_Sub))
3047 then
3048 Set_Is_Immediately_Visible (Priv_Sub, False);
3049 end if;
3050
3051 if Is_Visible_Dependent (Priv_Sub) then
3052 Preserve_Full_Attributes
3053 (Priv_Sub, Full_View (Priv_Sub));
3054 Replace_Elmt (Priv_Elmt, Full_View (Priv_Sub));
3055 Exchange_Declarations (Priv_Sub);
3056 end if;
3057 end if;
3058
3059 Next_Elmt (Priv_Elmt);
3060 end loop;
3061 3164
3062 -- Now restore the type itself to its private view 3165 -- Now restore the type itself to its private view
3063 3166
3064 Exchange_Declarations (Id); 3167 Exchange_Declarations (Id);
3065 3168
3150 Do_Abstract_States : Boolean := False) return Boolean 3253 Do_Abstract_States : Boolean := False) return Boolean
3151 is 3254 is
3152 E : Entity_Id; 3255 E : Entity_Id;
3153 3256
3154 Requires_Body : Boolean := False; 3257 Requires_Body : Boolean := False;
3155 -- Flag set when the unit has at least one construct that requries 3258 -- Flag set when the unit has at least one construct that requires
3156 -- completion in a body. 3259 -- completion in a body.
3157 3260
3158 begin 3261 begin
3159 -- Imported entity never requires body. Right now, only subprograms can 3262 -- Imported entity never requires body. Right now, only subprograms can
3160 -- be imported, but perhaps in the future we will allow import of 3263 -- be imported, but perhaps in the future we will allow import of
3213 Next_Entity (E); 3316 Next_Entity (E);
3214 end loop; 3317 end loop;
3215 3318
3216 -- A [generic] package that defines at least one non-null abstract state 3319 -- A [generic] package that defines at least one non-null abstract state
3217 -- requires a completion only when at least one other construct requires 3320 -- requires a completion only when at least one other construct requires
3218 -- a completion in a body (SPARK RM 7.1.4(4) and (6)). This check is not 3321 -- a completion in a body (SPARK RM 7.1.4(4) and (5)). This check is not
3219 -- performed if the caller requests this behavior. 3322 -- performed if the caller requests this behavior.
3220 3323
3221 if Do_Abstract_States 3324 if Do_Abstract_States
3222 and then Ekind_In (Pack_Id, E_Generic_Package, E_Package) 3325 and then Ekind_In (Pack_Id, E_Generic_Package, E_Package)
3223 and then Has_Non_Null_Abstract_State (Pack_Id) 3326 and then Has_Non_Null_Abstract_State (Pack_Id)