* [Ada] Pragma Eliminated applied to internal protected subprograms
@ 2010-06-17 13:15 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2010-06-17 13:15 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]
If a protected operation has been eliminated, an internal call to it from
another protected operation (that is itself eliminated) must not be expanded,
because the corresponding body has not been constructed.
The following must compile quietly:
gnatmake -f -gnatec=elim.out test_it.adb
---
procedure Test_It is
Var : Integer := 1;
protected Obj is
procedure Used;
procedure Unused;
private
end Obj;
protected body Obj is
procedure Hidden is
begin
Var := Var + 1;
end Hidden;
procedure Used is
begin
Var := Var + 1;
end;
procedure Unused is
begin
Hidden;
end;
end Obj;
begin
Obj.Used;
end Test_It;
---
file elim.out:
-- List of unused entities to be placed in gnat.adc. --
pragma Eliminate (Test_It, Unused, Source_Location => "test_it.adb:7");
pragma Eliminate (Test_It, Hidden, Source_Location => "test_it.adb:12");
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-06-17 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Expand_Call): Do not expand a call to an internal
protected operation if the subprogram has been eliminated.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 871 bytes --]
Index: exp_ch6.adb
===================================================================
--- exp_ch6.adb (revision 160905)
+++ exp_ch6.adb (working copy)
@@ -3095,12 +3095,14 @@ package body Exp_Ch6 is
-- In Ada 2005, this may be an indirect call to an access parameter that
-- is an access_to_subprogram. In that case the anonymous type has a
-- scope that is a protected operation, but the call is a regular one.
+ -- In either case do not expand call if subprogram is eliminated.
Scop := Scope (Subp);
if Nkind (N) /= N_Entry_Call_Statement
and then Is_Protected_Type (Scop)
and then Ekind (Subp) /= E_Subprogram_Type
+ and then not Is_Eliminated (Subp)
then
-- If the call is an internal one, it is rewritten as a call to the
-- corresponding unprotected subprogram.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-17 13:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-17 13:15 [Ada] Pragma Eliminated applied to internal protected subprograms Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).