From c6840e83cc062932453294d553b7bfeafe54e0c1 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 25 Apr 2017 11:47:33 +0200 Subject: [PATCH] [multiple changes] 2017-04-25 Bob Duff * sem_ch8.adb (Use_One_Type): If a use_type_clause is redundant, set its Used_Operations to empty. This is only necessary for use clauses that appear in the parent of a generic child unit, because those use clauses get reanalyzed when we instantiate the generic, and we don't want the Used_Operations carried over from the original context (where it was probably not redundant). 2017-04-25 Hristian Kirtchev * exp_ch6.adb: Minor reformatting. From-SVN: r247169 --- gcc/ada/ChangeLog | 14 ++++++++++++++ gcc/ada/exp_ch6.adb | 8 ++++---- gcc/ada/sem_ch8.adb | 13 ++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e108648cf6b..9f06f0cd210 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2017-04-25 Bob Duff + + * sem_ch8.adb (Use_One_Type): If a use_type_clause + is redundant, set its Used_Operations to empty. This is only + necessary for use clauses that appear in the parent of a generic + child unit, because those use clauses get reanalyzed when we + instantiate the generic, and we don't want the Used_Operations + carried over from the original context (where it was probably + not redundant). + +2017-04-25 Hristian Kirtchev + + * exp_ch6.adb: Minor reformatting. + 2017-04-25 Bob Duff * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 8c4868d7eb3..c6b235cffaa 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -6635,10 +6635,10 @@ package body Exp_Ch6 is Attribute_Name => Name_Tag); end if; - if not CodePeer_Mode then - -- CodePeer doesn't do anything useful with - -- Ada.Tags.Type_Specific_Data components + -- CodePeer does not do anything useful with + -- Ada.Tags.Type_Specific_Data components. + if not CodePeer_Mode then Insert_Action (Exp, Make_Raise_Program_Error (Loc, Condition => @@ -6647,7 +6647,7 @@ package body Exp_Ch6 is Right_Opnd => Make_Integer_Literal (Loc, Scope_Depth (Enclosing_Dynamic_Scope (Scope_Id)))), - Reason => PE_Accessibility_Check_Failed)); + Reason => PE_Accessibility_Check_Failed)); end if; end; diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index a3d8f40a9ae..d44cef2d819 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -9200,11 +9200,22 @@ package body Sem_Ch8 is ("incomplete type from limited view " & "cannot appear in use clause", Id); + -- If the use clause is redundant, Used_Operations will usually be + -- empty, but we need to set it to empty here in one case: If we are + -- instantiating a generic library unit, then we install the ancestors + -- of that unit in the scope stack, which involves reprocessing use + -- clauses in those ancestors. Such a use clause will typically have a + -- nonempty Used_Operations unless it was redundant in the generic unit, + -- even if it is redundant at the place of the instantiation. + + elsif Redundant_Use (Id) then + Set_Used_Operations (Parent (Id), New_Elmt_List); + -- If the subtype mark designates a subtype in a different package, -- we have to check that the parent type is visible, otherwise the -- use type clause is a noop. Not clear how to do that??? - elsif not Redundant_Use (Id) then + else Set_In_Use (T); -- If T is tagged, primitive operators on class-wide operands -- 2.30.2