[Ada] Work around problematic interaction with public symbol generation
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 11 Apr 2020 16:28:49 +0000 (18:28 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 17 Jun 2020 08:14:03 +0000 (04:14 -0400)
2020-06-17  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_First>:
Do not replace the bound for an array type if it is public.

gcc/ada/exp_attr.adb

index 51cda82..ea36be0 100644 (file)
@@ -3424,7 +3424,14 @@ package body Exp_Attr is
          --  reference. Note that this must be in keeping with what is done
          --  for scalar types in order for range checks to be elided in loops.
 
-         elsif Is_Array_Type (Ptyp) and then Is_Constrained (Ptyp) then
+         --  However, avoid doing it if the array type is public because, in
+         --  this case, we effectively rely on the back end to create public
+         --  symbols with consistent names across units for the array bounds.
+
+         elsif Is_Array_Type (Ptyp)
+           and then Is_Constrained (Ptyp)
+           and then not Is_Public (Ptyp)
+         then
             declare
                Bnd : Node_Id;