aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-07-03 08:13:41 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-03 08:13:41 +0000
commitf51e316c7c7d0b2aad8b8444253369f2e819aee5 (patch)
tree3191fdef35b109604d0e104514166bfd0e0bf582 /gcc/ada
parent07ec36eed91154bd164081aed2dcb59d05910dc7 (diff)
downloadgcc-f51e316c7c7d0b2aad8b8444253369f2e819aee5.zip
gcc-f51e316c7c7d0b2aad8b8444253369f2e819aee5.tar.gz
gcc-f51e316c7c7d0b2aad8b8444253369f2e819aee5.tar.bz2
[Ada] Spurious error on predicate of subtype in generic
This patch fixes a spurious error on a dynamic predicate of a record subtype when the expression for the predicate includes a selected component that denotes a component of the subtype. 2019-07-03 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch8.adb (Find_Selected_Component): If the prefix is the current instance of a type or subtype, complete the resolution of the name by finding the component of the type denoted by the selector name. gcc/testsuite/ * gnat.dg/predicate4.adb, gnat.dg/predicate4_pkg.ads: New testcase. From-SVN: r272961
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_ch8.adb22
2 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 96c16bd..b236063 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-03 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch8.adb (Find_Selected_Component): If the prefix is the
+ current instance of a type or subtype, complete the resolution
+ of the name by finding the component of the type denoted by the
+ selector name.
+
2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
* doc/gnat_rm/interfacing_to_other_languages.rst (Interfacing to C):
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index a5e821d..8f2d245 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -7418,10 +7418,28 @@ package body Sem_Ch8 is
-- It is not an error if the prefix is the current instance of
-- type name, e.g. the expression of a type aspect, when it is
- -- analyzed for ASIS use.
+ -- analyzed for ASIS use, or within a generic unit. We still
+ -- have to verify that a component of that name exists, and
+ -- decorate the node accordingly.
elsif Is_Entity_Name (P) and then Is_Current_Instance (P) then
- null;
+ declare
+ Comp : Entity_Id;
+
+ begin
+ Comp := First_Entity (Entity (P));
+ while Present (Comp) loop
+ if Chars (Comp) = Chars (Selector_Name (N)) then
+ Set_Entity (N, Comp);
+ Set_Etype (N, Etype (Comp));
+ Set_Entity (Selector_Name (N), Comp);
+ Set_Etype (Selector_Name (N), Etype (Comp));
+ return;
+ end if;
+
+ Next_Entity (Comp);
+ end loop;
+ end;
elsif Ekind (P_Name) = E_Void then
Premature_Usage (P);