comparison gcc/ada/sem_ch8.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
4 -- -- 4 -- --
5 -- S E M _ C H 8 -- 5 -- S E M _ C H 8 --
6 -- -- 6 -- --
7 -- B o d y -- 7 -- B o d y --
8 -- -- 8 -- --
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- 9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
57 with Sem_Dim; use Sem_Dim; 57 with Sem_Dim; use Sem_Dim;
58 with Sem_Disp; use Sem_Disp; 58 with Sem_Disp; use Sem_Disp;
59 with Sem_Dist; use Sem_Dist; 59 with Sem_Dist; use Sem_Dist;
60 with Sem_Elab; use Sem_Elab; 60 with Sem_Elab; use Sem_Elab;
61 with Sem_Eval; use Sem_Eval; 61 with Sem_Eval; use Sem_Eval;
62 with Sem_Prag; use Sem_Prag;
62 with Sem_Res; use Sem_Res; 63 with Sem_Res; use Sem_Res;
63 with Sem_Util; use Sem_Util; 64 with Sem_Util; use Sem_Util;
64 with Sem_Type; use Sem_Type; 65 with Sem_Type; use Sem_Type;
65 with Stand; use Stand; 66 with Stand; use Stand;
66 with Sinfo; use Sinfo; 67 with Sinfo; use Sinfo;
1922 -- If Ren is a renaming of a formal function and its return 1923 -- If Ren is a renaming of a formal function and its return
1923 -- profile has a null exclusion, then Sub's return profile must 1924 -- profile has a null exclusion, then Sub's return profile must
1924 -- have one. Otherwise the subtype of Sub's return profile must 1925 -- have one. Otherwise the subtype of Sub's return profile must
1925 -- exclude null. 1926 -- exclude null.
1926 1927
1928 procedure Check_SPARK_Primitive_Operation (Subp_Id : Entity_Id);
1929 -- Ensure that a SPARK renaming denoted by its entity Subp_Id does not
1930 -- declare a primitive operation of a tagged type (SPARK RM 6.1.1(3)).
1931
1927 procedure Freeze_Actual_Profile; 1932 procedure Freeze_Actual_Profile;
1928 -- In Ada 2012, enforce the freezing rule concerning formal incomplete 1933 -- In Ada 2012, enforce the freezing rule concerning formal incomplete
1929 -- types: a callable entity freezes its profile, unless it has an 1934 -- types: a callable entity freezes its profile, unless it has an
1930 -- incomplete untagged formal (RM 13.14(10.2/3)). 1935 -- incomplete untagged formal (RM 13.14(10.2/3)).
1931 1936
2516 Error_Msg_N 2521 Error_Msg_N
2517 ("return must specify `NOT NULL`", 2522 ("return must specify `NOT NULL`",
2518 Result_Definition (Parent (Sub))); 2523 Result_Definition (Parent (Sub)));
2519 end if; 2524 end if;
2520 end Check_Null_Exclusion; 2525 end Check_Null_Exclusion;
2526
2527 -------------------------------------
2528 -- Check_SPARK_Primitive_Operation --
2529 -------------------------------------
2530
2531 procedure Check_SPARK_Primitive_Operation (Subp_Id : Entity_Id) is
2532 Prag : constant Node_Id := SPARK_Pragma (Subp_Id);
2533 Typ : Entity_Id;
2534
2535 begin
2536 -- Nothing to do when the subprogram is not subject to SPARK_Mode On
2537 -- because this check applies to SPARK code only.
2538
2539 if not (Present (Prag)
2540 and then Get_SPARK_Mode_From_Annotation (Prag) = On)
2541 then
2542 return;
2543
2544 -- Nothing to do when the subprogram is not a primitive operation
2545
2546 elsif not Is_Primitive (Subp_Id) then
2547 return;
2548 end if;
2549
2550 Typ := Find_Dispatching_Type (Subp_Id);
2551
2552 -- Nothing to do when the subprogram is a primitive operation of an
2553 -- untagged type.
2554
2555 if No (Typ) then
2556 return;
2557 end if;
2558
2559 -- At this point a renaming declaration introduces a new primitive
2560 -- operation for a tagged type.
2561
2562 Error_Msg_Node_2 := Typ;
2563 Error_Msg_NE
2564 ("subprogram renaming & cannot declare primitive for type & "
2565 & "(SPARK RM 6.1.1(3))", N, Subp_Id);
2566 end Check_SPARK_Primitive_Operation;
2521 2567
2522 --------------------------- 2568 ---------------------------
2523 -- Freeze_Actual_Profile -- 2569 -- Freeze_Actual_Profile --
2524 --------------------------- 2570 ---------------------------
2525 2571
2897 Set_Is_Pure (New_S, Is_Pure (Current_Scope)); 2943 Set_Is_Pure (New_S, Is_Pure (Current_Scope));
2898 end if; 2944 end if;
2899 2945
2900 -- Set SPARK mode from current context 2946 -- Set SPARK mode from current context
2901 2947
2902 Set_SPARK_Pragma (New_S, SPARK_Mode_Pragma); 2948 Set_SPARK_Pragma (New_S, SPARK_Mode_Pragma);
2903 Set_SPARK_Pragma_Inherited (New_S); 2949 Set_SPARK_Pragma_Inherited (New_S);
2904 2950
2905 Rename_Spec := Find_Corresponding_Spec (N); 2951 Rename_Spec := Find_Corresponding_Spec (N);
2906 2952
2907 -- Case of Renaming_As_Body 2953 -- Case of Renaming_As_Body
3007 3053
3008 else 3054 else
3009 Generate_Definition (New_S); 3055 Generate_Definition (New_S);
3010 New_Overloaded_Entity (New_S); 3056 New_Overloaded_Entity (New_S);
3011 3057
3012 if Is_Entity_Name (Nam) 3058 if not (Is_Entity_Name (Nam)
3013 and then Is_Intrinsic_Subprogram (Entity (Nam)) 3059 and then Is_Intrinsic_Subprogram (Entity (Nam)))
3014 then 3060 then
3015 null;
3016 else
3017 Check_Delayed_Subprogram (New_S); 3061 Check_Delayed_Subprogram (New_S);
3018 end if; 3062 end if;
3063
3064 -- Verify that a SPARK renaming does not declare a primitive
3065 -- operation of a tagged type.
3066
3067 Check_SPARK_Primitive_Operation (New_S);
3019 end if; 3068 end if;
3020 3069
3021 -- There is no need for elaboration checks on the new entity, which may 3070 -- There is no need for elaboration checks on the new entity, which may
3022 -- be called before the next freezing point where the body will appear. 3071 -- be called before the next freezing point where the body will appear.
3023 -- Elaboration checks refer to the real entity, not the one created by 3072 -- Elaboration checks refer to the real entity, not the one created by
3203 elsif not Ekind_In (Old_S, E_Function, E_Procedure) then 3252 elsif not Ekind_In (Old_S, E_Function, E_Procedure) then
3204 null; 3253 null;
3205 3254
3206 elsif Requires_Overriding (Old_S) 3255 elsif Requires_Overriding (Old_S)
3207 or else 3256 or else
3208 (Is_Abstract_Subprogram (Old_S) 3257 (Is_Abstract_Subprogram (Old_S)
3209 and then Present (Find_Dispatching_Type (Old_S)) 3258 and then Present (Find_Dispatching_Type (Old_S))
3210 and then 3259 and then not Is_Abstract_Type (Find_Dispatching_Type (Old_S)))
3211 not Is_Abstract_Type (Find_Dispatching_Type (Old_S)))
3212 then 3260 then
3213 Error_Msg_N 3261 Error_Msg_N
3214 ("renamed entity cannot be subprogram that requires overriding " 3262 ("renamed entity cannot be subprogram that requires overriding "
3215 & "(RM 8.5.4 (5.1))", N); 3263 & "(RM 8.5.4 (5.1))", N);
3216 end if; 3264 end if;
3642 3690
3643 -- Check if we are looking at an Ada 2012 defaulted formal subprogram 3691 -- Check if we are looking at an Ada 2012 defaulted formal subprogram
3644 -- and mark any use_package_clauses that affect the visibility of the 3692 -- and mark any use_package_clauses that affect the visibility of the
3645 -- implicit generic actual. 3693 -- implicit generic actual.
3646 3694
3695 -- Also, we may be looking at an internal renaming of a user-defined
3696 -- subprogram created for a generic formal subprogram association,
3697 -- which will also have to be marked here. This can occur when the
3698 -- corresponding formal subprogram contains references to other generic
3699 -- formals.
3700
3647 if Is_Generic_Actual_Subprogram (New_S) 3701 if Is_Generic_Actual_Subprogram (New_S)
3648 and then (Is_Intrinsic_Subprogram (New_S) or else From_Default (N)) 3702 and then (Is_Intrinsic_Subprogram (New_S)
3703 or else From_Default (N)
3704 or else Nkind (N) = N_Subprogram_Renaming_Declaration)
3649 then 3705 then
3650 Mark_Use_Clauses (New_S); 3706 Mark_Use_Clauses (New_S);
3651 3707
3652 -- Handle overloaded subprograms 3708 -- Handle overloaded subprograms
3653 3709
3732 end loop; 3788 end loop;
3733 end Analyze_Package_Name_List; 3789 end Analyze_Package_Name_List;
3734 3790
3735 -- Local variables 3791 -- Local variables
3736 3792
3737 Ghost_Id : Entity_Id := Empty; 3793 Pack : Entity_Id;
3738 Living_Id : Entity_Id := Empty;
3739 Pack : Entity_Id;
3740 3794
3741 -- Start of processing for Analyze_Use_Package 3795 -- Start of processing for Analyze_Use_Package
3742 3796
3743 begin 3797 begin
3744 Check_SPARK_05_Restriction ("use clause is not allowed", N); 3798 Check_SPARK_05_Restriction ("use clause is not allowed", N);
3820 if Nkind (Parent (N)) = N_Compilation_Unit then 3874 if Nkind (Parent (N)) = N_Compilation_Unit then
3821 Check_In_Previous_With_Clause (N, Name (N)); 3875 Check_In_Previous_With_Clause (N, Name (N));
3822 end if; 3876 end if;
3823 3877
3824 Use_One_Package (N, Name (N)); 3878 Use_One_Package (N, Name (N));
3825 3879 end if;
3826 -- Capture the first Ghost package and the first living package 3880
3827 3881 Mark_Ghost_Clause (N);
3828 if Is_Entity_Name (Name (N)) then
3829 Pack := Entity (Name (N));
3830
3831 if Is_Ghost_Entity (Pack) then
3832 if No (Ghost_Id) then
3833 Ghost_Id := Pack;
3834 end if;
3835
3836 elsif No (Living_Id) then
3837 Living_Id := Pack;
3838 end if;
3839 end if;
3840 end if;
3841 end Analyze_Use_Package; 3882 end Analyze_Use_Package;
3842 3883
3843 ---------------------- 3884 ----------------------
3844 -- Analyze_Use_Type -- 3885 -- Analyze_Use_Type --
3845 ---------------------- 3886 ----------------------
3866 3907
3867 -- There are many cases where a use_type_clause may be reanalyzed due to 3908 -- There are many cases where a use_type_clause may be reanalyzed due to
3868 -- manipulation of the scope stack so we much guard against those cases 3909 -- manipulation of the scope stack so we much guard against those cases
3869 -- here, otherwise, we must add the new use_type_clause to the previous 3910 -- here, otherwise, we must add the new use_type_clause to the previous
3870 -- use_type_clause chain in order to mark redundant use_type_clauses as 3911 -- use_type_clause chain in order to mark redundant use_type_clauses as
3871 -- used. 3912 -- used. When the redundant use-type clauses appear in a parent unit and
3913 -- a child unit we must prevent a circularity in the chain that would
3914 -- otherwise result from the separate steps of analysis and installation
3915 -- of the parent context.
3872 3916
3873 if Present (Current_Use_Clause (E)) 3917 if Present (Current_Use_Clause (E))
3874 and then Current_Use_Clause (E) /= N 3918 and then Current_Use_Clause (E) /= N
3919 and then Prev_Use_Clause (Current_Use_Clause (E)) /= N
3875 and then No (Prev_Use_Clause (N)) 3920 and then No (Prev_Use_Clause (N))
3876 then 3921 then
3877 Set_Prev_Use_Clause (N, Current_Use_Clause (E)); 3922 Set_Prev_Use_Clause (N, Current_Use_Clause (E));
3878 end if; 3923 end if;
3879 3924
4179 4224
4180 if Is_Compilation_Unit (New_S) then 4225 if Is_Compilation_Unit (New_S) then
4181 Error_Msg_N 4226 Error_Msg_N
4182 ("a library unit can only rename another library unit", N); 4227 ("a library unit can only rename another library unit", N);
4183 end if; 4228 end if;
4229
4230 -- We suppress elaboration warnings for the resulting entity, since
4231 -- clearly they are not needed, and more particularly, in the case
4232 -- of a generic formal subprogram, the resulting entity can appear
4233 -- after the instantiation itself, and thus look like a bogus case
4234 -- of access before elaboration.
4235
4236 if Legacy_Elaboration_Checks then
4237 Set_Suppress_Elaboration_Warnings (New_S);
4238 end if;
4184 end Attribute_Renaming; 4239 end Attribute_Renaming;
4185 4240
4186 ---------------------- 4241 ----------------------
4187 -- Chain_Use_Clause -- 4242 -- Chain_Use_Clause --
4188 ---------------------- 4243 ----------------------
4262 else 4317 else
4263 Insert_After (N, B_Node); 4318 Insert_After (N, B_Node);
4264 Analyze (B_Node); 4319 Analyze (B_Node);
4265 end if; 4320 end if;
4266 4321
4267 if Is_Intrinsic_Subprogram (Old_S) and then not In_Instance then 4322 if Is_Intrinsic_Subprogram (Old_S)
4323 and then not In_Instance
4324 and then not Relaxed_RM_Semantics
4325 then
4268 Error_Msg_N 4326 Error_Msg_N
4269 ("subprogram used in renaming_as_body cannot be intrinsic", 4327 ("subprogram used in renaming_as_body cannot be intrinsic",
4270 Name (N)); 4328 Name (N));
4271 end if; 4329 end if;
4272 4330
5893 -- Come here with entity set 5951 -- Come here with entity set
5894 5952
5895 <<Done>> 5953 <<Done>>
5896 Check_Restriction_No_Use_Of_Entity (N); 5954 Check_Restriction_No_Use_Of_Entity (N);
5897 5955
5898 -- Save the scenario for later examination by the ABE Processing phase 5956 -- Annotate the tree by creating a variable reference marker in case the
5899 5957 -- original variable reference is folded or optimized away. The variable
5900 Record_Elaboration_Scenario (N); 5958 -- reference marker is automatically saved for later examination by the
5959 -- ABE Processing phase. Variable references which act as actuals in a
5960 -- call require special processing and are left to Resolve_Actuals. The
5961 -- reference is a write when it appears on the left hand side of an
5962 -- assignment.
5963
5964 if Needs_Variable_Reference_Marker
5965 (N => N,
5966 Calls_OK => False)
5967 then
5968 declare
5969 Is_Assignment_LHS : constant Boolean := Is_LHS (N) = Yes;
5970
5971 begin
5972 Build_Variable_Reference_Marker
5973 (N => N,
5974 Read => not Is_Assignment_LHS,
5975 Write => Is_Assignment_LHS);
5976 end;
5977 end if;
5901 end Find_Direct_Name; 5978 end Find_Direct_Name;
5902 5979
5903 ------------------------ 5980 ------------------------
5904 -- Find_Expanded_Name -- 5981 -- Find_Expanded_Name --
5905 ------------------------ 5982 ------------------------
5967 return False; 6044 return False;
5968 end In_Abstract_View_Pragma; 6045 end In_Abstract_View_Pragma;
5969 6046
5970 -- Local variables 6047 -- Local variables
5971 6048
5972 Selector : constant Node_Id := Selector_Name (N); 6049 Selector : constant Node_Id := Selector_Name (N);
5973 Candidate : Entity_Id := Empty; 6050
6051 Candidate : Entity_Id := Empty;
5974 P_Name : Entity_Id; 6052 P_Name : Entity_Id;
5975 Id : Entity_Id; 6053 Id : Entity_Id;
5976 6054
5977 -- Start of processing for Find_Expanded_Name 6055 -- Start of processing for Find_Expanded_Name
5978 6056
6254 end if; 6332 end if;
6255 6333
6256 -- If this is a selection from Ada, System or Interfaces, then 6334 -- If this is a selection from Ada, System or Interfaces, then
6257 -- we assume a missing with for the corresponding package. 6335 -- we assume a missing with for the corresponding package.
6258 6336
6259 if Is_Known_Unit (N) then 6337 if Is_Known_Unit (N)
6338 and then not (Present (Entity (Prefix (N)))
6339 and then Scope (Entity (Prefix (N))) /=
6340 Standard_Standard)
6341 then
6260 if not Error_Posted (N) then 6342 if not Error_Posted (N) then
6261 Error_Msg_Node_2 := Selector; 6343 Error_Msg_Node_2 := Selector;
6262 Error_Msg_N -- CODEFIX 6344 Error_Msg_N -- CODEFIX
6263 ("missing `WITH &.&;`", Prefix (N)); 6345 ("missing `WITH &.&;`", Prefix (N));
6264 end if; 6346 end if;
6527 Mark_Use_Clauses (N); 6609 Mark_Use_Clauses (N);
6528 end if; 6610 end if;
6529 6611
6530 Check_Restriction_No_Use_Of_Entity (N); 6612 Check_Restriction_No_Use_Of_Entity (N);
6531 6613
6532 -- Save the scenario for later examination by the ABE Processing phase 6614 -- Annotate the tree by creating a variable reference marker in case the
6533 6615 -- original variable reference is folded or optimized away. The variable
6534 Record_Elaboration_Scenario (N); 6616 -- reference marker is automatically saved for later examination by the
6617 -- ABE Processing phase. Variable references which act as actuals in a
6618 -- call require special processing and are left to Resolve_Actuals. The
6619 -- reference is a write when it appears on the left hand side of an
6620 -- assignment.
6621
6622 if Needs_Variable_Reference_Marker
6623 (N => N,
6624 Calls_OK => False)
6625 then
6626 declare
6627 Is_Assignment_LHS : constant Boolean := Is_LHS (N) = Yes;
6628
6629 begin
6630 Build_Variable_Reference_Marker
6631 (N => N,
6632 Read => not Is_Assignment_LHS,
6633 Write => Is_Assignment_LHS);
6634 end;
6635 end if;
6535 end Find_Expanded_Name; 6636 end Find_Expanded_Name;
6536 6637
6537 -------------------- 6638 --------------------
6538 -- Find_Most_Prev -- 6639 -- Find_Most_Prev --
6539 -------------------- 6640 --------------------
7012 Set_Etype (P, Designated_Type (Etype (Prefix (P)))); 7113 Set_Etype (P, Designated_Type (Etype (Prefix (P))));
7013 end; 7114 end;
7014 end if; 7115 end if;
7015 7116
7016 -- If the selected component appears within a default expression 7117 -- If the selected component appears within a default expression
7017 -- and it has an actual subtype, the pre-analysis has not yet 7118 -- and it has an actual subtype, the preanalysis has not yet
7018 -- completed its analysis, because Insert_Actions is disabled in 7119 -- completed its analysis, because Insert_Actions is disabled in
7019 -- that context. Within the init proc of the enclosing type we 7120 -- that context. Within the init proc of the enclosing type we
7020 -- must complete this analysis, if an actual subtype was created. 7121 -- must complete this analysis, if an actual subtype was created.
7021 7122
7022 elsif Inside_Init_Proc then 7123 elsif Inside_Init_Proc then
8292 -- Mark_Use_Type -- 8393 -- Mark_Use_Type --
8293 ------------------- 8394 -------------------
8294 8395
8295 procedure Mark_Use_Type (E : Entity_Id) is 8396 procedure Mark_Use_Type (E : Entity_Id) is
8296 Curr : Node_Id; 8397 Curr : Node_Id;
8398 Base : Entity_Id;
8297 8399
8298 begin 8400 begin
8299 -- Ignore void types and unresolved string literals and primitives 8401 -- Ignore void types and unresolved string literals and primitives
8300 8402
8301 if Nkind (E) = N_String_Literal 8403 if Nkind (E) = N_String_Literal
8303 or else not Is_Type (Etype (E)) 8405 or else not Is_Type (Etype (E))
8304 then 8406 then
8305 return; 8407 return;
8306 end if; 8408 end if;
8307 8409
8410 -- Primitives with class-wide operands might additionally render
8411 -- their base type's use_clauses effective - so do a recursive check
8412 -- here.
8413
8414 Base := Base_Type (Etype (E));
8415
8416 if Ekind (Base) = E_Class_Wide_Type then
8417 Mark_Use_Type (Base);
8418 end if;
8419
8308 -- The package containing the type or operator function being used 8420 -- The package containing the type or operator function being used
8309 -- may be in use as well, so mark any use_package_clauses for it as 8421 -- may be in use as well, so mark any use_package_clauses for it as
8310 -- effective. There are also additional sanity checks performed here 8422 -- effective. There are also additional sanity checks performed here
8311 -- for ignoring previous errors. 8423 -- for ignoring previous errors.
8312 8424
8313 Mark_Use_Package (Scope (Base_Type (Etype (E)))); 8425 Mark_Use_Package (Scope (Base));
8314 8426
8315 if Nkind (E) in N_Op 8427 if Nkind (E) in N_Op
8316 and then Present (Entity (E)) 8428 and then Present (Entity (E))
8317 and then Present (Scope (Entity (E))) 8429 and then Present (Scope (Entity (E)))
8318 then 8430 then
8319 Mark_Use_Package (Scope (Entity (E))); 8431 Mark_Use_Package (Scope (Entity (E)));
8320 end if; 8432 end if;
8321 8433
8322 Curr := Current_Use_Clause (Base_Type (Etype (E))); 8434 Curr := Current_Use_Clause (Base);
8323 while Present (Curr) 8435 while Present (Curr)
8324 and then not Is_Effective_Use_Clause (Curr) 8436 and then not Is_Effective_Use_Clause (Curr)
8325 loop 8437 loop
8326 -- Current use_type_clause may render other use_package_clauses 8438 -- Current use_type_clause may render other use_package_clauses
8327 -- effective. 8439 -- effective.
8369 8481
8370 elsif (Ekind (Id) in Overloadable_Kind 8482 elsif (Ekind (Id) in Overloadable_Kind
8371 or else Ekind_In (Id, E_Generic_Function, 8483 or else Ekind_In (Id, E_Generic_Function,
8372 E_Generic_Procedure)) 8484 E_Generic_Procedure))
8373 and then (Is_Potentially_Use_Visible (Id) 8485 and then (Is_Potentially_Use_Visible (Id)
8374 or else Is_Intrinsic_Subprogram (Id)) 8486 or else Is_Intrinsic_Subprogram (Id)
8487 or else (Ekind_In (Id, E_Function, E_Procedure)
8488 and then Is_Generic_Actual_Subprogram (Id)))
8375 then 8489 then
8376 Mark_Parameters (Id); 8490 Mark_Parameters (Id);
8377 end if; 8491 end if;
8378 8492
8379 -- Handle nodes 8493 -- Handle nodes
8422 8536
8423 function Most_Descendant_Use_Clause 8537 function Most_Descendant_Use_Clause
8424 (Clause1 : Entity_Id; 8538 (Clause1 : Entity_Id;
8425 Clause2 : Entity_Id) return Entity_Id 8539 Clause2 : Entity_Id) return Entity_Id
8426 is 8540 is
8427 Scope1, Scope2 : Entity_Id; 8541 Scope1 : Entity_Id;
8542 Scope2 : Entity_Id;
8428 8543
8429 begin 8544 begin
8430 if Clause1 = Clause2 then 8545 if Clause1 = Clause2 then
8431 return Clause1; 8546 return Clause1;
8432 end if; 8547 end if;
8836 8951
8837 Withn := 8952 Withn :=
8838 Make_With_Clause (Loc, 8953 Make_With_Clause (Loc,
8839 Name => 8954 Name =>
8840 Make_Expanded_Name (Loc, 8955 Make_Expanded_Name (Loc,
8841 Chars => Chars (System_Aux_Id), 8956 Chars => Chars (System_Aux_Id),
8842 Prefix => New_Occurrence_Of (Scope (System_Aux_Id), Loc), 8957 Prefix =>
8958 New_Occurrence_Of (Scope (System_Aux_Id), Loc),
8843 Selector_Name => New_Occurrence_Of (System_Aux_Id, Loc))); 8959 Selector_Name => New_Occurrence_Of (System_Aux_Id, Loc)));
8844 8960
8845 Set_Entity (Name (Withn), System_Aux_Id); 8961 Set_Entity (Name (Withn), System_Aux_Id);
8846 8962
8963 Set_Corresponding_Spec (Withn, System_Aux_Id);
8964 Set_First_Name (Withn);
8965 Set_Implicit_With (Withn);
8847 Set_Library_Unit (Withn, Cunit (Unum)); 8966 Set_Library_Unit (Withn, Cunit (Unum));
8848 Set_Corresponding_Spec (Withn, System_Aux_Id);
8849 Set_First_Name (Withn, True);
8850 Set_Implicit_With (Withn, True);
8851 8967
8852 Insert_After (With_Sys, Withn); 8968 Insert_After (With_Sys, Withn);
8853 Mark_Rewrite_Insertion (Withn); 8969 Mark_Rewrite_Insertion (Withn);
8854 Set_Context_Installed (Withn); 8970 Set_Context_Installed (Withn);
8855 8971
9019 ----------------------------- 9135 -----------------------------
9020 -- Update_Use_Clause_Chain -- 9136 -- Update_Use_Clause_Chain --
9021 ----------------------------- 9137 -----------------------------
9022 9138
9023 procedure Update_Use_Clause_Chain is 9139 procedure Update_Use_Clause_Chain is
9140
9024 procedure Update_Chain_In_Scope (Level : Int); 9141 procedure Update_Chain_In_Scope (Level : Int);
9025 -- Iterate through one level in the scope stack verifying each use-type 9142 -- Iterate through one level in the scope stack verifying each use-type
9026 -- clause within said level is used then reset the Current_Use_Clause 9143 -- clause within said level is used then reset the Current_Use_Clause
9027 -- to a redundant use clause outside of the current ending scope if such 9144 -- to a redundant use clause outside of the current ending scope if such
9028 -- a clause exists. 9145 -- a clause exists.
9055 9172
9056 if Check_Unreferenced 9173 if Check_Unreferenced
9057 and then Comes_From_Source (Curr) 9174 and then Comes_From_Source (Curr)
9058 and then not Is_Effective_Use_Clause (Curr) 9175 and then not Is_Effective_Use_Clause (Curr)
9059 and then not In_Instance 9176 and then not In_Instance
9177 and then not In_Inlined_Body
9060 then 9178 then
9061 -- We are dealing with a potentially unused use_package_clause 9179 -- We are dealing with a potentially unused use_package_clause
9062 9180
9063 if Nkind (Curr) = N_Use_Package_Clause then 9181 if Nkind (Curr) = N_Use_Package_Clause then
9064 9182
9065 -- Renamings and formal subprograms may cause the associated 9183 -- Renamings and formal subprograms may cause the associated
9066 -- to be marked as effective instead of the original. 9184 -- node to be marked as effective instead of the original.
9067 9185
9068 if not (Present (Associated_Node (N)) 9186 if not (Present (Associated_Node (N))
9069 and then Present 9187 and then Present
9070 (Current_Use_Clause 9188 (Current_Use_Clause
9071 (Associated_Node (N))) 9189 (Associated_Node (N)))
9398 9516
9399 return; 9517 return;
9400 9518
9401 -- Warn about detected redundant clauses 9519 -- Warn about detected redundant clauses
9402 9520
9403 elsif In_Open_Scopes (P) and not Force then 9521 elsif not Force
9522 and then In_Open_Scopes (P)
9523 and then not Is_Hidden_Open_Scope (P)
9524 then
9404 if Warn_On_Redundant_Constructs and then P = Current_Scope then 9525 if Warn_On_Redundant_Constructs and then P = Current_Scope then
9405 Error_Msg_NE -- CODEFIX 9526 Error_Msg_NE -- CODEFIX
9406 ("& is already use-visible within itself?r?", 9527 ("& is already use-visible within itself?r?",
9407 Pack_Name, P); 9528 Pack_Name, P);
9408 end if; 9529 end if;
9863 -- no redundancy between an outer use_clause and one that appears 9984 -- no redundancy between an outer use_clause and one that appears
9864 -- within the generic. 9985 -- within the generic.
9865 9986
9866 and then not Spec_Reloaded_For_Body 9987 and then not Spec_Reloaded_For_Body
9867 and then not In_Instance 9988 and then not In_Instance
9989 and then not In_Inlined_Body
9868 then 9990 then
9869 -- The type already has a use clause 9991 -- The type already has a use clause
9870 9992
9871 if In_Use (T) then 9993 if In_Use (T) then
9872 9994