[Ada] Spurious restriction violation on Ghost code

2019-10-10  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_ch6.adb (Expand_Simple_Function_Return_Statement): If the
	function to which the return statement applies is an
	Ignored_Ghost_Function, do not indicate that it uses the
	secondary stack when the return type is unconstrained.

From-SVN: r276814
This commit is contained in:
Ed Schonberg 2019-10-10 15:23:14 +00:00 committed by Pierre-Marie de Rodat
parent 2f26abccd0
commit 95a7982243
2 changed files with 11 additions and 15 deletions

View File

@ -1,15 +1,6 @@
2019-10-10 Bob Duff <duff@adacore.com>
2019-10-10 Ed Schonberg <schonberg@adacore.com>
* libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb,
libgnat/a-cborma.adb, libgnat/a-cborse.adb,
libgnat/a-cdlili.adb, libgnat/a-cidlli.adb,
libgnat/a-cihama.adb, libgnat/a-cihase.adb,
libgnat/a-cimutr.adb, libgnat/a-ciorma.adb,
libgnat/a-ciorse.adb, libgnat/a-cobove.adb,
libgnat/a-cohama.adb, libgnat/a-cohase.adb,
libgnat/a-coinve.adb, libgnat/a-comutr.adb,
libgnat/a-conhel.adb, libgnat/a-convec.adb,
libgnat/a-coorma.adb, libgnat/a-coorse.adb (Reference,
Constant_Reference): Use Busy instead of Lock, so we forbid
tampering with cursors, rather than tampering with elements.
* exp_ch6.adb (Expand_Simple_Function_Return_Statement): If the
function to which the return statement applies is an
Ignored_Ghost_Function, do not indicate that it uses the
secondary stack when the return type is unconstrained.

View File

@ -6895,7 +6895,12 @@ package body Exp_Ch6 is
elsif Is_Thunk (Current_Scope) and then Is_Incomplete_Type (Exptyp) then
return;
elsif not Requires_Transient_Scope (R_Type) then
-- A return statement from a Ghost function does not use the secondary
-- stack (or any other one).
elsif not Requires_Transient_Scope (R_Type)
or else Is_Ignored_Ghost_Entity (Scope_Id)
then
-- Mutable records with variable-length components are not returned
-- on the sec-stack, so we need to make sure that the back end will