summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_elim.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-18 13:01:07 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-18 13:01:07 +0000
commit931fa8c000065dc5b66843018276cca3e4cb8480 (patch)
tree96454f5efbaef73201d0218ecd6d79b444fffe51 /gcc/ada/sem_elim.adb
parent4320e73005b2d4a3a0d85e00e2e52e9614b16442 (diff)
downloadgcc-931fa8c000065dc5b66843018276cca3e4cb8480.tar.gz
2010-06-18 Pascal Obry <obry@adacore.com>
* make.adb, prj-nmsc.adb: Fix source filenames casing in debug output. 2010-06-18 Vincent Celier <celier@adacore.com> * gnatcmd.adb: For gnatcheck, add -gnatec= switch for a global configuration pragmas file and, if -U is not used, for a local one. 2010-06-18 Ed Schonberg <schonberg@adacore.com> * sem_elim.adb (Check_Eliminated): Use full information on entity name when it is given in the pragma by a selected component. (Check_For_Eliminated_Subprogram): Do no emit error if within a instance body that is itself within a generic unit. * sem_ch12.adb (Analyze_Subprogram_Instance): If the subprogram is eliminated, mark as well the anonymous subprogram that is its alias and appears within the wrapper package. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160986 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_elim.adb')
-rw-r--r--gcc/ada/sem_elim.adb73
1 files changed, 66 insertions, 7 deletions
diff --git a/gcc/ada/sem_elim.adb b/gcc/ada/sem_elim.adb
index bb42159b99e..9917b1f3511 100644
--- a/gcc/ada/sem_elim.adb
+++ b/gcc/ada/sem_elim.adb
@@ -29,6 +29,7 @@ with Errout; use Errout;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
+with Opt; use Opt;
with Sem; use Sem;
with Sem_Prag; use Sem_Prag;
with Sem_Util; use Sem_Util;
@@ -287,7 +288,8 @@ package body Sem_Elim is
goto Continue;
end if;
- -- Find enclosing unit
+ -- Find enclosing unit, and verify that its name and those of its
+ -- parents match.
Scop := Cunit_Entity (Current_Sem_Unit);
@@ -329,9 +331,6 @@ package body Sem_Elim is
end if;
Scop := Scope (Scop);
- while Ekind (Scop) = E_Block loop
- Scop := Scope (Scop);
- end loop;
if Scop /= Standard_Standard and then J = 1 then
goto Continue;
@@ -342,8 +341,60 @@ package body Sem_Elim is
goto Continue;
end if;
- -- Check for case of given entity is a library level subprogram
- -- and we have the single parameter Eliminate case, a match!
+ if Present (Elmt.Entity_Node)
+ and then Elmt.Entity_Scope /= null
+ then
+
+ -- Check that names of enclosing scopes match.
+ -- Skip blocks and wrapper package of subprogram instances,
+ -- which do not appear in the pragma.
+
+ Scop := Scope (E);
+
+ for J in reverse Elmt.Entity_Scope'Range loop
+ while Ekind (Scop) = E_Block
+ or else
+ (Ekind (Scop) = E_Package
+ and then Is_Wrapper_Package (Scop))
+ loop
+ Scop := Scope (Scop);
+ end loop;
+
+ if Elmt.Entity_Scope (J) /= Chars (Scop) then
+ if Ekind (Scop) /= E_Protected_Type
+ or else Comes_From_Source (Scop)
+ then
+ goto Continue;
+
+ -- For simple protected declarations, retrieve the source
+ -- name of the object, which appeared in the Eliminate
+ -- pragma.
+
+ else
+ declare
+ Decl : constant Node_Id :=
+ Original_Node (Parent (Scop));
+
+ begin
+ if Elmt.Entity_Scope (J) /=
+ Chars (Defining_Identifier (Decl))
+ then
+ if J > 0 then
+ null;
+ end if;
+ goto Continue;
+ end if;
+ end;
+ end if;
+
+ end if;
+
+ Scop := Scope (Scop);
+ end loop;
+ end if;
+
+ -- If given entity is a library level subprogram and pragma had a
+ -- single parameter, a match!
if Is_Compilation_Unit (E)
and then Is_Subprogram (E)
@@ -672,7 +723,15 @@ package body Sem_Elim is
Enclosing_Subp := Enclosing_Subprogram (Enclosing_Subp);
end loop;
- Eliminate_Error_Msg (N, Ultimate_Subp);
+ -- Emit error, unless we are within an instance body and
+ -- the expander is disabled, which indicates an instance
+ -- within an enclosing generic.
+
+ if In_Instance_Body and then not Expander_Active then
+ null;
+ else
+ Eliminate_Error_Msg (N, Ultimate_Subp);
+ end if;
end if;
end Check_For_Eliminated_Subprogram;