aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-07-05 07:03:20 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-05 07:03:20 +0000
commitc365eb26e87eab31f55b760fe4220b68fb952b72 (patch)
tree98a60ccbff6e973252d405c7435ac3c2f93304ac
parent9880061b346330e7c986016bdec75f38659f8793 (diff)
downloadgcc-c365eb26e87eab31f55b760fe4220b68fb952b72.zip
gcc-c365eb26e87eab31f55b760fe4220b68fb952b72.tar.gz
gcc-c365eb26e87eab31f55b760fe4220b68fb952b72.tar.bz2
[Ada] Fix position of subprogram body generated for static predicate
2019-07-05 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch13.adb (Build_Predicate_Functions): If a subtype that carries a static predicate aspect is frozen immediately after its declaration, ensure that the generated function body created for predicate checking is inserted after the corresponding subprogram declaration, which is created at the point the declaration is elaborated. From-SVN: r273122
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/sem_ch13.adb10
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6da90f2..c5dcd03 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-05 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch13.adb (Build_Predicate_Functions): If a subtype that
+ carries a static predicate aspect is frozen immediately after
+ its declaration, ensure that the generated function body created
+ for predicate checking is inserted after the corresponding
+ subprogram declaration, which is created at the point the
+ declaration is elaborated.
+
2019-07-05 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch7.adb (Cleanup_Record): Use the underlying type when
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index b18f74b..4c74366 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -8902,9 +8902,15 @@ package body Sem_Ch13 is
Expression => Expr))));
-- The declaration has been analyzed when created, and placed
- -- after type declaration. Insert body itself after freeze node.
+ -- after type declaration. Insert body itself after freeze node,
+ -- unless subprogram declaration is already there, in which case
+ -- body better be placed afterwards.
- Insert_After_And_Analyze (N, FBody);
+ if FDecl = Next (N) then
+ Insert_After_And_Analyze (FDecl, FBody);
+ else
+ Insert_After_And_Analyze (N, FBody);
+ end if;
-- The defining identifier of a quantified expression carries the
-- scope in which the type appears, but when unnesting we need