aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog14
-rw-r--r--gcc/ada/gnat_rm.texi2
-rw-r--r--gcc/ada/sem_ch12.adb28
-rw-r--r--gcc/ada/sem_elim.adb33
4 files changed, 53 insertions, 24 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1054620..d472b28 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,17 @@
+2010-06-17 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch12.adb (Mark_Context): Refine placement of Withed_Body flag, so
+ that it marks a unit as needed by a spec only if the corresponding
+ instantiation appears in that spec (and not in the corresponding body).
+ * sem_elim.adb (Check_Eliminated): If we are within a subunit, the name
+ in the pragma Eliminate has been parsed as a child unit, but the
+ current compilation unit is in fact the parent in which the subunit is
+ embedded.
+
+2010-06-17 Vincent Celier <celier@adacore.com>
+
+ * gnat_rm.texi: Fix typo
+
2010-06-17 Robert Dewar <dewar@adacore.com>
* sem_util.adb: Minor reformatting
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 99811c7..8e226c6 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -16271,7 +16271,7 @@ be copied. The directory must exist, must be distinct from the project's
object directory and source directories of all projects in the project tree,
and must be writable.
-@item Library_Src_Dir
+@item Library_ALI_Dir
Expression must be a path name. The attribute defines the
directory in which the ALI files of a Library will
be copied. The directory must exist, must be distinct from the project's
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index eecb533..b9ff3b9 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -10388,11 +10388,16 @@ package body Sem_Ch12 is
------------------
procedure Mark_Context (Inst_Decl : Node_Id; Gen_Decl : Node_Id) is
- Inst_CU : constant Unit_Number_Type := Get_Source_Unit (Inst_Decl);
+ Inst_CU : constant Unit_Number_Type := Get_Code_Unit (Inst_Decl);
Gen_CU : constant Unit_Number_Type := Get_Source_Unit (Gen_Decl);
Clause : Node_Id;
begin
+ -- Note that we use Get_Code_Unit to determine the position of the
+ -- instantiation, because it may itself appear within another instance
+ -- and we need to mark the context of the enclosing unit, not that of
+ -- the unit that contains the corresponding generic.
+
Clause := First (Context_Items (Cunit (Inst_CU)));
while Present (Clause) loop
if Nkind (Clause) = N_With_Clause
@@ -10403,27 +10408,6 @@ package body Sem_Ch12 is
Next (Clause);
end loop;
-
- -- If the instance appears within another instantiated unit, check
- -- whether it appears in the main unit, and indicate the need for
- -- the body of the enclosing instance as well.
-
- if In_Extended_Main_Code_Unit (Inst_Decl)
- and then Instantiation_Location (Sloc (Inst_Decl)) /= No_Location
- and then Present (Library_Unit (Cunit (Main_Unit)))
- and then Cunit (Inst_CU) /= Library_Unit (Cunit (Main_Unit))
- then
- Clause := First (Context_Items (Library_Unit (Cunit (Main_Unit))));
- while Present (Clause) loop
- if Nkind (Clause) = N_With_Clause
- and then Library_Unit (Clause) = Cunit (Gen_CU)
- then
- Set_Withed_Body (Clause, Cunit (Gen_CU));
- end if;
-
- Next (Clause);
- end loop;
- end if;
end Mark_Context;
---------------------
diff --git a/gcc/ada/sem_elim.adb b/gcc/ada/sem_elim.adb
index aa2c190..ecc4ed6 100644
--- a/gcc/ada/sem_elim.adb
+++ b/gcc/ada/sem_elim.adb
@@ -234,6 +234,7 @@ package body Sem_Elim is
Elmt : Access_Elim_Data;
Scop : Entity_Id;
Form : Entity_Id;
+ Up : Nat;
begin
if No_Elimination then
@@ -292,7 +293,37 @@ package body Sem_Elim is
-- Now see if compilation unit matches
- for J in reverse Elmt.Unit_Name'Range loop
+ Up := Elmt.Unit_Name'Last;
+
+ -- If we are within a subunit, the name in the pragma has been
+ -- parsed as a child unit, but the current compilation unit is
+ -- in fact the parent in which the subunit is embedded. We must
+ -- skip the first name which is that of the subunit to match
+ -- the pragma specification.
+
+ declare
+ Par : Node_Id;
+
+ begin
+ Par := Parent (E);
+ while Present (Par) loop
+ if Nkind (Par) = N_Subunit then
+ if Chars (Defining_Unit_Name (Proper_Body (Par))) =
+ Elmt.Unit_Name (Up)
+ then
+ Up := Up - 1;
+ exit;
+
+ else
+ goto Continue;
+ end if;
+ end if;
+
+ Par := Parent (Par);
+ end loop;
+ end;
+
+ for J in reverse Elmt.Unit_Name'First .. Up loop
if Elmt.Unit_Name (J) /= Chars (Scop) then
goto Continue;
end if;