aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-01-11 08:53:15 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-01-11 08:53:15 +0000
commit52c5090a4f940459ac3e38bcee0fd9f5f86a4eff (patch)
treef6ee50a6149b595f15bbdd02da83116a39fa1a8a /gcc/ada
parent2e01b698bd52e3b4af71a5cb03e647d3ac8cf601 (diff)
downloadgcc-52c5090a4f940459ac3e38bcee0fd9f5f86a4eff.zip
gcc-52c5090a4f940459ac3e38bcee0fd9f5f86a4eff.tar.gz
gcc-52c5090a4f940459ac3e38bcee0fd9f5f86a4eff.tar.bz2
[Ada] Crash on expression function as completion, with implicit dereference
An implicit dereference freezes the corresponding designated type. Most implicit dereferences are made explicit during expansion, but this is not the case for a dispatching call where the the controlling parameter and the corresponding controlling argument are access to a tagged type. In that case, to enforce the rule that an expression function that is a completion freezes type references within, we must locate controlling arguments of an access type and freeze explicitly the corresponding designated type. 2018-01-11 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch6.adb (Freeze_Expr_Types): If an access value is the controlling argument of a dispatching call. freeze the corresponding designated type. gcc/testsuite/ * gnat.dg/expr_func3.adb, gnat.dg/expr_func3.ads: New testcase. From-SVN: r256507
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/sem_ch6.adb14
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9681fbd..fc30104 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-11 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch6.adb (Freeze_Expr_Types): If an access value is the
+ controlling argument of a dispatching call. freeze the corresponding
+ designated type.
+
2018-01-11 Ben Brosgol <brosgol@adacore.com>
* doc/Makefile: Add Sphinx option -W to treat warnings as errors.
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index cb5b3e7..1c0495f 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -423,6 +423,20 @@ package body Sem_Ch6 is
Check_And_Freeze_Type (Designated_Type (Etype (Node)));
end if;
+ -- An implicit dereference freezes the designated type. In the
+ -- case of a dispatching call whose controlling argument is an
+ -- access type, the dereference is not made explicit, so we must
+ -- check for such a call and freeze the designated type.
+
+ if Nkind (Node) in N_Has_Etype
+ and then Present (Etype (Node))
+ and then Is_Access_Type (Etype (Node))
+ and then Nkind (Parent (Node)) = N_Function_Call
+ and then Node = Controlling_Argument (Parent (Node))
+ then
+ Check_And_Freeze_Type (Designated_Type (Etype (Node)));
+ end if;
+
-- No point in posting several errors on the same expression
if Serious_Errors_Detected > 0 then