[Ada] Spurious error on Type'Access and <>
authorArnaud Charlet <charlet@adacore.com>
Mon, 30 Nov 2020 08:11:40 +0000 (03:11 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 17 Dec 2020 10:49:19 +0000 (05:49 -0500)
gcc/ada/

* sem_attr.adb (OK_Self_Reference): Return True if node does not
come from source (e.g. a rewritten aggregate).

gcc/ada/sem_attr.adb

index d5970a1..1f769a5 100644 (file)
@@ -782,6 +782,13 @@ package body Sem_Attr is
             Par : Node_Id;
 
          begin
+            --  If N does not come from source, the reference is assumed to be
+            --  valid.
+
+            if not Comes_From_Source (N) then
+               return True;
+            end if;
+
             Par := Parent (N);
             while Present (Par)
               and then
@@ -1032,9 +1039,7 @@ package body Sem_Attr is
                --  expression comes from source, e.g. when a single component
                --  association in an aggregate has a box association.
 
-               elsif Ada_Version >= Ada_2005
-                 and then OK_Self_Reference
-               then
+               elsif Ada_Version >= Ada_2005 and then OK_Self_Reference then
                   null;
 
                --  OK if reference to current instance of a protected object