diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-16 15:09:14 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-16 15:09:14 +0200 |
commit | c1c5e0faa84bd01c866f7f2930cc628a770b3c2a (patch) | |
tree | f3a07e9782740e8755f1c247c90dbdfc719b140a | |
parent | b72d8ad5dd2004077a3abe777461afeb8851ee42 (diff) | |
download | gcc-c1c5e0faa84bd01c866f7f2930cc628a770b3c2a.zip gcc-c1c5e0faa84bd01c866f7f2930cc628a770b3c2a.tar.gz gcc-c1c5e0faa84bd01c866f7f2930cc628a770b3c2a.tar.bz2 |
[multiple changes]
2009-04-16 Ed Schonberg <schonberg@adacore.com>
* 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 <ebotcazou@adacore.com>
* g-pehage.adb (Initialize): Fix off-by-one error.
From-SVN: r146186
-rw-r--r-- | gcc/ada/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/ada/g-pehage.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 40 |
3 files changed, 49 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0d0e450..fa83526 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2009-04-16 Ed Schonberg <schonberg@adacore.com> + + * 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 <ebotcazou@adacore.com> + + * g-pehage.adb (Initialize): Fix off-by-one error. + 2009-04-16 Tristan Gingold <gingold@adacore.com> * init.c: Detect real stack overflow on Darwin. diff --git a/gcc/ada/g-pehage.adb b/gcc/ada/g-pehage.adb index 129cecc..93f05b8 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 8087231..21da890 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; ------------------- |