From 1f25038381847b32fda35dd91ae0053635509a83 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 1 Aug 2011 17:13:25 +0200 Subject: [PATCH] [multiple changes] 2011-08-01 Thomas Quinot * sem_ch6.adb (Enter_Overloaded_Entity): Do not warn about a declaration being hidden when overriding an implicit inherited subprogram. * par-ch10.adb (P_Compilation_Unit): In syntax check only mode (-gnats), do not complain about a source file that contains only a pragma No_Body. 2011-08-01 Ed Schonberg * sem_ch5.adb (Analyze_Iterator_Scheme): Do not overwrite type of loop variable if already set. From-SVN: r177046 --- gcc/ada/ChangeLog | 14 ++++++++++++++ gcc/ada/par-ch10.adb | 16 +++++++++++++++- gcc/ada/sem_ch5.adb | 11 ++++++++++- gcc/ada/sem_ch6.adb | 11 ++++++++--- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1e5bba7ff1b..bc668042bc7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2011-08-01 Thomas Quinot + + * sem_ch6.adb (Enter_Overloaded_Entity): Do not warn about a + declaration being hidden when overriding an implicit inherited + subprogram. + * par-ch10.adb (P_Compilation_Unit): In syntax check only mode + (-gnats), do not complain about a source file that contains only a + pragma No_Body. + +2011-08-01 Ed Schonberg + + * sem_ch5.adb (Analyze_Iterator_Scheme): Do not overwrite type of loop + variable if already set. + 2011-08-01 Arnaud Charlet * g-socket-dummy.adb, s-osinte-linux.ads, g-socket-dummy.ads, diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb index 37992b60059..d3c1c162ec9 100644 --- a/gcc/ada/par-ch10.adb +++ b/gcc/ada/par-ch10.adb @@ -114,6 +114,7 @@ package body Ch10 is Config_Pragmas : List_Id; P : Node_Id; SR_Present : Boolean; + No_Body : Boolean; Cunit_Error_Flag : Boolean := False; -- This flag is set True if we have to scan for a compilation unit @@ -145,6 +146,10 @@ package body Ch10 is SR_Present := False; + -- If we see a pragma No_Body, remember not to complain about no body + + No_Body := False; + if Token = Tok_Pragma then Save_Scan_State (Scan_State); Item := P_Pragma; @@ -179,6 +184,10 @@ package body Ch10 is Save_Scan_State (Scan_State); Item := P_Pragma; + if Item /= Error and then Pragma_Name (Item) = Name_No_Body then + No_Body := True; + end if; + if Item = Error or else not Is_Configuration_Pragma_Name (Pragma_Name (Item)) then @@ -301,7 +310,12 @@ package body Ch10 is else if Operating_Mode = Check_Syntax and then Token = Tok_EOF then - Error_Msg_SC ("?file contains no compilation units"); + + -- Do not complain if there is a pragma No_Body + + if not No_Body then + Error_Msg_SC ("?file contains no compilation units"); + end if; else Error_Msg_SC ("compilation unit expected"); Cunit_Error_Flag := True; diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 90a6926f579..96c778d3f83 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1947,7 +1947,16 @@ package body Sem_Ch5 is Make_Index (DS, LP); Set_Ekind (Id, E_Loop_Parameter); - Set_Etype (Id, Etype (DS)); + + -- If the loop is part of a predicate or precondition, it may + -- be analyzed twice, once in the source and once on the copy + -- used to check conformance. Preserve the original itype + -- because the second one may be created in a different scope, + -- e.g. a precondition procedure, leading to a crash in GIGI. + + if No (Etype (Id)) or else Etype (Id) = Any_Type then + Set_Etype (Id, Etype (DS)); + end if; -- Treat a range as an implicit reference to the type, to -- inhibit spurious warnings. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 46d3a20b604..2633fca0275 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -6048,7 +6048,13 @@ package body Sem_Ch6 is -- of the real danger that different operators may be applied in -- various parts of the program. - if (not Is_Overloadable (E) or else Subtype_Conformant (E, S)) + -- Note that if E and S have the same scope, there is never any + -- hiding. Either the two conflict, and the program is illegal, + -- or S is overriding an implicit inherited subprogram. + + if Scope (E) /= Scope (S) + and then (not Is_Overloadable (E) + or else Subtype_Conformant (E, S)) and then (Is_Immediately_Visible (E) or else Is_Potentially_Use_Visible (S)) @@ -6059,8 +6065,7 @@ package body Sem_Ch6 is elsif Nkind (S) = N_Defining_Operator_Symbol and then - Scope ( - Base_Type (Etype (First_Formal (S)))) /= Scope (S) + Scope (Base_Type (Etype (First_Formal (S)))) /= Scope (S) then Error_Msg_N ("declaration of & hides predefined operator?", S); -- 2.30.2