]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 13:09:14 +0000 (15:09 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Apr 2009 13:09:14 +0000 (15:09 +0200)
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

gcc/ada/ChangeLog
gcc/ada/g-pehage.adb
gcc/ada/sem_ch12.adb

index 0d0e450d986ac3477a581378dde9805305f74d4e..fa835267d9dabfb15caf81a50f6997931f36b817 100644 (file)
@@ -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.
index 129cecc7659936aeff6c2127a82ce45d8cb42917..93f05b824606168489a0739e2827b3cbd5517693 100644 (file)
@@ -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;
index 808723177b3583e535f2f55433ad691ddf94acc7..21da8901fcd045f5eb23a7be33dbdc703bfa33ce 100644 (file)
@@ -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;
 
    -------------------