From: Arnaud Charlet Date: Thu, 16 Apr 2009 13:09:14 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.5.0~6535 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1c5e0faa84bd01c866f7f2930cc628a770b3c2a;p=thirdparty%2Fgcc.git [multiple changes] 2009-04-16 Ed Schonberg * sem_ch12.adb (Preanalyze_Actuals): If the instance is a child unit that hides an outer homograph, make that homograph invisible when analyzing the actuals, to to prevent illegal direct visibility on it. 2009-04-16 Eric Botcazou * g-pehage.adb (Initialize): Fix off-by-one error. From-SVN: r146186 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0d0e450d986a..fa835267d9da 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2009-04-16 Ed Schonberg + + * sem_ch12.adb (Preanalyze_Actuals): If the instance is a child unit + that hides an outer homograph, make that homograph invisible when + analyzing the actuals, to to prevent illegal direct visibility on it. + +2009-04-16 Eric Botcazou + + * g-pehage.adb (Initialize): Fix off-by-one error. + 2009-04-16 Tristan Gingold * init.c: Detect real stack overflow on Darwin. diff --git a/gcc/ada/g-pehage.adb b/gcc/ada/g-pehage.adb index 129cecc76599..93f05b824606 100644 --- a/gcc/ada/g-pehage.adb +++ b/gcc/ada/g-pehage.adb @@ -1146,7 +1146,7 @@ package body GNAT.Perfect_Hash_Generators is -- words already there because a previous computation failed. We are -- currently retrying and the reduced words have to be deallocated. - for W in NK .. WT.Last loop + for W in Reduced (0) .. WT.Last loop Free_Word (WT.Table (W)); end loop; IT.Init; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 808723177b35..21da8901fcd0 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -10888,8 +10888,31 @@ package body Sem_Ch12 is Act : Node_Id; Errs : constant Int := Serious_Errors_Detected; + Cur : Entity_Id := Empty; + -- Current homograph of the instance name + + Vis : Boolean; + -- Saved visibility status of the current homograph + begin Assoc := First (Generic_Associations (N)); + + -- If the instance is a child unit, its name may hide an outer homonym, + -- so make it invisible to perform name resolution on the actuals. + + if Nkind (Defining_Unit_Name (N)) = N_Defining_Program_Unit_Name + and then Present + (Current_Entity (Defining_Identifier (Defining_Unit_Name (N)))) + then + Cur := Current_Entity (Defining_Identifier (Defining_Unit_Name (N))); + if Is_Compilation_Unit (Cur) then + Vis := Is_Immediately_Visible (Cur); + Set_Is_Immediately_Visible (Cur, False); + else + Cur := Empty; + end if; + end if; + while Present (Assoc) loop if Nkind (Assoc) /= N_Others_Choice then Act := Explicit_Generic_Actual_Parameter (Assoc); @@ -10924,8 +10947,8 @@ package body Sem_Ch12 is if Nkind (Expr) = N_Subtype_Indication then Analyze (Subtype_Mark (Expr)); - -- Analyze separately each discriminant constraint, - -- when given with a named association. + -- Analyze separately each discriminant constraint, when + -- given with a named association. declare Constr : Node_Id; @@ -10967,12 +10990,25 @@ package body Sem_Ch12 is Set_Is_Instantiated (Entity (Name (N))); end if; + if Present (Cur) then + -- For the case of a child instance hiding an outer homonym, + -- provide additional warning which might explain the error. + + Set_Is_Immediately_Visible (Cur, Vis); + Error_Msg_NE ("& hides outer unit with the same name?", + N, Defining_Unit_Name (N)); + end if; + Abandon_Instantiation (Act); end if; end if; Next (Assoc); end loop; + + if Present (Cur) then + Set_Is_Immediately_Visible (Cur, Vis); + end if; end Preanalyze_Actuals; -------------------