This patch removes a spurious warning about an unused formal parameter when
the type of the psrameter has an Implicit_Dereference aspect and the parameter
is used in a call wthin the subbprogram body.
The following must compile quietly:
gcc -c -gnatwa tr.adb
---
with Con;
package Tr is
procedure P (R : Con.R_Type);
end;
---
package body Tr is
procedure Q (R : Con.R_Type) is
begin
Con.Foo (R);
end;
procedure P (R : Con.R_Type) is
begin
Q (R);
end;
end Tr;
---
package Con is
type C_Type is record
X : Integer;
end record;
procedure Foo (X : in out C_Type);
type R_Type (C : not null access C_Type)
is tagged limited null record
with Implicit_Dereference => C;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-11-09 Ed Schonberg <[email protected]>
* sem_res.adb (Resolve): If expression is an entity whose type has
implicit dereference, generate reference to it, because no reference is
generated for an overloaded entity during analysis, given that its
identity may not be known.
Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 254563)
+++ sem_res.adb (working copy)
@@ -2448,11 +2448,18 @@
-- AI05-0139-2: Expression is overloaded because type has
-- implicit dereference. If type matches context, no implicit
- -- dereference is involved.
+ -- dereference is involved. If the expression is an entity,
+ -- generate a reference to it, as this is not done for an
+ -- overloaded construct during analysis.
elsif Has_Implicit_Dereference (Expr_Type) then
Set_Etype (N, Expr_Type);
Set_Is_Overloaded (N, False);
+
+ if Is_Entity_Name (N) then
+ Generate_Reference (Entity (N), N);
+ end if;
+
exit Interp_Loop;
elsif Is_Overloaded (N)