Patchwork [Ada] Fix spurious "prefix of dereference must be an access type"

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 31, 2011, 9:34 a.m.
Message ID <20110831093404.GA19957@adacore.com>
Download mbox | patch
Permalink /patch/112485/
State New
Headers show

Comments

Arnaud Charlet - Aug. 31, 2011, 9:34 a.m.
This patch fixes an obscure bug, in which an error "prefix of dereference must
be an access type" is given incorrectly. The spurious error would occur in an
instance of a generic if an implicit dereference of an expression of a private
type is used.
No simple test is available.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-31  Bob Duff  <duff@adacore.com>

	* exp_ch4.adb (Expand_N_Selected_Component): Use the full type, in case
	the access type is private; we don't care about privacy in expansion.

Patch

Index: exp_ch4.adb
===================================================================
--- exp_ch4.adb	(revision 178368)
+++ exp_ch4.adb	(working copy)
@@ -7920,6 +7920,7 @@ 
       --  Insert explicit dereference if required
 
       if Is_Access_Type (Ptyp) then
+         Set_Etype (P, Ptyp); -- in case it's private
          Insert_Explicit_Dereference (P);
          Analyze_And_Resolve (P, Designated_Type (Ptyp));