Bug 36777 - Protected type cannot have access taken from its body.
Summary: Protected type cannot have access taken from its body.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Samuel Tardieu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-09 21:18 UTC by Maciej Sobczak
Modified: 2008-08-13 11:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-08-03 14:59:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Sobczak 2008-07-09 21:18:15 UTC
Protected type cannot have access taken from its body.
The following should work:

   protected type P is
      procedure Foo;
   end P;

   protected body P is
      procedure Foo is
         Ptr : access P;  -- here P denotes the type P
      begin
         Ptr := P'Access; -- here P denotes the "this" instance of P
      end;
   end P;

The compiler complains that 'Access cannot be applied to a type, which is in conflict with AARM 9.4-21/2.
Comment 1 Samuel Tardieu 2008-08-13 10:59:05 UTC
Subject: Bug 36777

Author: sam
Date: Wed Aug 13 10:57:43 2008
New Revision: 139051

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139051
Log:
    gcc/ada/
	PR ada/36777
	* sem_util.ads, sem_util.adb (Is_Protected_Self_Reference): New.
	* sem_attr.adb (Check_Type): The current instance of a protected
	object is not a type name.
	(Analyze_Access_Attribute): Accept instances of protected objects.
	(Analyze_Attribute, Attribute_Address clause): Ditto.
	* exp_attr.adb (Expand_N_Attribute_Reference): Rewrite
	the prefix as being the current instance if needed.

    gcc/testsuite/
	PR ada/36777
	* gnat.dg/protected_self_ref1.adb, gnat.dg/protected_self_ref2.adb:
	New.

Added:
    trunk/gcc/testsuite/gnat.dg/protected_self_ref1.adb
    trunk/gcc/testsuite/gnat.dg/protected_self_ref2.adb
Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/exp_attr.adb
    trunk/gcc/ada/sem_attr.adb
    trunk/gcc/ada/sem_util.adb
    trunk/gcc/ada/sem_util.ads
    trunk/gcc/testsuite/ChangeLog

Comment 2 Samuel Tardieu 2008-08-13 11:01:01 UTC
This bug has been fixed in GCC SVN trunk. Thanks for the report.