aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-08-21 14:44:46 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-08-21 14:44:46 +0000
commit8a2f6bbe45fe2dff64d613365fe2ddb2b1922e2f (patch)
tree07042f92f76214893d3caaeb6592aaaf64c481d9 /gcc/ada
parentd8251d001b3507ffb80b26f4d17f1daa99a5dc4a (diff)
downloadgcc-8a2f6bbe45fe2dff64d613365fe2ddb2b1922e2f.zip
gcc-8a2f6bbe45fe2dff64d613365fe2ddb2b1922e2f.tar.gz
gcc-8a2f6bbe45fe2dff64d613365fe2ddb2b1922e2f.tar.bz2
[Ada] Compiler abort on call to expr. function for default discriminant
If a discriminant specification has a default that is a call to an expression function, that function has to be frozen at the point of a call to the initialization procedure for an object of the record type, even though the call does not appear to come from source. 2018-08-21 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_res.adb (Resolve_Call): Force the freezing of an expression function that is called to provide a default value for a defaulted discriminant in an object initialization. gcc/testsuite/ * gnat.dg/expr_func5.adb: New testcase. From-SVN: r263710
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/sem_res.adb13
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 31420a3..7bae0cf 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2018-08-21 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_res.adb (Resolve_Call): Force the freezing of an
+ expression function that is called to provide a default value
+ for a defaulted discriminant in an object initialization.
+
2018-08-21 Hristian Kirtchev <kirtchev@adacore.com>
* libgnat/g-dynhta.adb, libgnat/g-dynhta.ads: New package
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index ddfa543..13612aa 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -6067,7 +6067,10 @@ package body Sem_Res is
-- (including the body of another expression function) which would
-- place the freeze node in the wrong scope. An expression function
-- is frozen in the usual fashion, by the appearance of a real body,
- -- or at the end of a declarative part.
+ -- or at the end of a declarative part. However an implcit call to
+ -- an expression function may appear when it is part of a default
+ -- expression in a call to an initialiation procedure, and must be
+ -- frozen now, even if the body is inserted at a later point.
if Is_Entity_Name (Subp)
and then not In_Spec_Expression
@@ -6076,6 +6079,14 @@ package body Sem_Res is
(not Is_Expression_Function_Or_Completion (Entity (Subp))
or else Scope (Entity (Subp)) = Current_Scope)
then
+ if Is_Expression_Function (Entity (Subp)) then
+
+ -- Force freeze of expression function in call.
+
+ Set_Comes_From_Source (Subp, True);
+ Set_Must_Not_Freeze (Subp, False);
+ end if;
+
Freeze_Expression (Subp);
end if;