[Ada] Do not issue restriction violations on ignored ghost code

2019-12-16  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* exp_ch6.adb: Fix comment.
	* sem_res.adb (Resolve_Call): Do not check No_Recursion
	restriction or indirectly No_Secondary_Stack restriction, when
	inside an ignored ghost subprogram.

From-SVN: r279419
This commit is contained in:
Yannick Moy 2019-12-16 10:33:41 +00:00 committed by Pierre-Marie de Rodat
parent f17f5647c5
commit bee69f3368
3 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2019-12-16 Yannick Moy <moy@adacore.com>
* exp_ch6.adb: Fix comment.
* sem_res.adb (Resolve_Call): Do not check No_Recursion
restriction or indirectly No_Secondary_Stack restriction, when
inside an ignored ghost subprogram.
2019-12-16 Arnaud Charlet <charlet@adacore.com>
* impunit.adb: Add a-nbnbin, a-nbnbre, a-nubinu to Ada 2020

View File

@ -6934,8 +6934,8 @@ package body Exp_Ch6 is
elsif Is_Thunk (Current_Scope) and then Is_Incomplete_Type (Exptyp) then
return;
-- A return statement from a Ghost function does not use the secondary
-- stack (or any other one).
-- A return statement from an ignored 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)

View File

@ -6675,7 +6675,9 @@ package body Sem_Res is
-- checkable, the case of calling an immediately containing
-- subprogram is easy to catch.
Check_Restriction (No_Recursion, N);
if not Is_Ignored_Ghost_Entity (Nam) then
Check_Restriction (No_Recursion, N);
end if;
-- If the recursive call is to a parameterless subprogram,
-- then even if we can't statically detect infinite
@ -6820,9 +6822,13 @@ package body Sem_Res is
then
null;
-- A return statement from an ignored Ghost function does not use the
-- secondary stack (or any other one).
elsif Expander_Active
and then Ekind_In (Nam, E_Function, E_Subprogram_Type)
and then Requires_Transient_Scope (Etype (Nam))
and then not Is_Ignored_Ghost_Entity (Nam)
then
Establish_Transient_Scope (N, Manage_Sec_Stack => True);