]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Spurious accessibility error on allocator in generic instance
authorJustin Squirek <squirek@adacore.com>
Tue, 22 Jun 2021 21:31:55 +0000 (17:31 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 20 Sep 2021 12:31:29 +0000 (12:31 +0000)
gcc/ada/

* exp_ch4.adb (Expand_N_Type_Conversion): Add guard to protect
against calculating accessibility levels against internal
compiler-generated types.

gcc/ada/exp_ch4.adb

index 16f513e32265f77dc400704ea9fc3c01e1af8588..45b9c769360ca1e32ba7aa9ca1f45c5b6213bfba 100644 (file)
@@ -12361,10 +12361,16 @@ package body Exp_Ch4 is
          --  an instantiation, otherwise the conversion will already have been
          --  rejected as illegal.
 
-         --  Note: warnings are issued by the analyzer for the instance cases
+         --  Note: warnings are issued by the analyzer for the instance cases,
+         --  and, since we are late in expansion, a check is performed to
+         --  verify that neither the target type nor the operand type are
+         --  internally generated - as this can lead to spurious errors when,
+         --  for example, the operand type is a result of BIP expansion.
 
          elsif In_Instance_Body
            and then Statically_Deeper_Relation_Applies (Target_Type)
+           and then not Is_Internal (Target_Type)
+           and then not Is_Internal (Operand_Type)
            and then
              Type_Access_Level (Operand_Type) > Type_Access_Level (Target_Type)
          then