]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Spurious error on referene to subcoponrnt in dynamic predicate
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jan 2018 08:54:17 +0000 (08:54 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jan 2018 08:54:17 +0000 (08:54 +0000)
commit3e406e6ddeeba9716022bf9a9ec3a20f1daa443a
tree96695641879293e94fc9892d6c86eba0019cef4f
parent2149b10c2bd7703202c255966ef916cb80cf229b
[Ada] Spurious error on referene to subcoponrnt in dynamic predicate

This patch fixes a visibility error in the expression for a dynamic predicate
of a record type, when the expression contains a reference to a subcomponent
of the record given by a selected component whose prefix is the name of the
enclosing component.

Executing

   gnatmake -q -gnata main
   ./main

must yield:

   TGV OK
   Amtrak broken, as usual

----
with Text_IO; use Text_IO;
with Recpred; use Recpred;
procedure Main is
   TGV : Train_Data;
   Amtrak : Train_Data;
begin
  TGV  := (20, (10,10));
  Put_Line ("TGV OK");

  begin
     Amtrak := (30, (40, 40));
  exception
     when Others =>
        Put_Line ("Amtrak broken, as usual");
  end;
end;
----
package Recpred is

   type Train_Position is record
      TTD : Integer;
      VSS : Integer;
   end record;

   type Train_Data is record
      MA             : Integer;
      Front_Position : Train_Position;
   end record
     with Dynamic_Predicate => MA >= Front_Position.TTD;

end Recpred;

2018-01-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* sem_ch13.adb (Replace_Type_Ref): Handle properly reference to a
subcomponent of the current entity when building the body for a dynamic
predicate function for a record with composite subcomponents.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256514 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb