[gcc r11-1227] [Ada] Fix missing insertion of explicit dereference in instance

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Thu Jun 11 10:02:33 GMT 2020


https://gcc.gnu.org/g:419c355c7a871513e1065b7cec32dd456eb4a0e5

commit r11-1227-g419c355c7a871513e1065b7cec32dd456eb4a0e5
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Mar 19 14:50:32 2020 +0100

    [Ada] Fix missing insertion of explicit dereference in instance
    
    2020-06-11  Eric Botcazou  <ebotcazou@adacore.com>
    
    gcc/ada/
    
            * sem_res.adb (Resolve_Implicit_Dereference): In an instance,
            reset the type of the prefix if it is private before building
            the dereference.

Diff:
---
 gcc/ada/sem_res.adb | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 71c9ed2b0f0..5fa74f0f48b 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8740,6 +8740,17 @@ package body Sem_Res is
       Desig_Typ : Entity_Id;
 
    begin
+      --  In an instance the proper view may not always be correct for
+      --  private types, see e.g. Sem_Type.Covers for similar handling.
+
+      if Is_Private_Type (Etype (P))
+        and then Present (Full_View (Etype (P)))
+        and then Is_Access_Type (Full_View (Etype (P)))
+        and then In_Instance
+      then
+         Set_Etype (P, Full_View (Etype (P)));
+      end if;
+
       if Is_Access_Type (Etype (P)) then
          Desig_Typ := Implicitly_Designated_Type (Etype (P));
          Insert_Explicit_Dereference (P);


More information about the Gcc-cvs mailing list