Commit 3c5d07ab by Hristian Kirtchev Committed by Pierre-Marie de Rodat

[Ada] Spurious tampering check failure

This patch modifies the transient scope mechanism to create a scope when the
condition of an iteration scheme returns a controlled result or involves the
secondary stack. As a result, a while loop which iterates over a container
properly manages the tampering bit at each iteration of the loop.

2018-05-31  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch7.adb (Find_Transient_Context): An iteration scheme is a valid
	boudary for a transient scope.

gcc/testsuite/

	* gnat.dg/tampering_check1.adb, gnat.dg/tampering_check1_ivectors.ads,
	gnat.dg/tampering_check1_trim.adb, gnat.dg/tampering_check1_trim.ads:
	New testcase.

From-SVN: r261006
parent 9977c785
2018-05-31 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch7.adb (Find_Transient_Context): An iteration scheme is a valid
boudary for a transient scope.
2018-05-31 Valentine Reboul <reboul@adacore.com> 2018-05-31 Valentine Reboul <reboul@adacore.com>
* gnatvsn.ads: Rename "GPL" version to "Community". * gnatvsn.ads: Rename "GPL" version to "Community".
......
...@@ -4987,6 +4987,7 @@ package body Exp_Ch7 is ...@@ -4987,6 +4987,7 @@ package body Exp_Ch7 is
| N_Entry_Body_Formal_Part | N_Entry_Body_Formal_Part
| N_Exit_Statement | N_Exit_Statement
| N_If_Statement | N_If_Statement
| N_Iteration_Scheme
| N_Terminate_Alternative | N_Terminate_Alternative
=> =>
pragma Assert (Present (Prev)); pragma Assert (Present (Prev));
...@@ -5058,13 +5059,11 @@ package body Exp_Ch7 is ...@@ -5058,13 +5059,11 @@ package body Exp_Ch7 is
return Curr; return Curr;
end if; end if;
-- An iteration scheme or an Ada 2012 iterator specification is -- An Ada 2012 iterator specification is not a valid context
-- not a valid context because Analyze_Iteration_Scheme already -- because Analyze_Iterator_Specification already employs special
-- employs special processing for them. -- processing for it.
when N_Iteration_Scheme when N_Iterator_Specification =>
| N_Iterator_Specification
=>
return Empty; return Empty;
when N_Loop_Parameter_Specification => when N_Loop_Parameter_Specification =>
......
2018-05-31 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/tampering_check1.adb, gnat.dg/tampering_check1_ivectors.ads,
gnat.dg/tampering_check1_trim.adb, gnat.dg/tampering_check1_trim.ads:
New testcase.
2018-05-31 Eric Botcazou <ebotcazou@adacore.com> 2018-05-31 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/size_clause1.adb: New testcase. * gnat.dg/size_clause1.adb: New testcase.
......
-- { dg-do run }
with Tampering_Check1_IVectors; use Tampering_Check1_IVectors;
with Tampering_Check1_Trim;
procedure Tampering_Check1 is
V : Vector;
begin
V.Append (-1);
V.Append (-2);
V.Append (-3);
Tampering_Check1_Trim (V);
end Tampering_Check1;
with Ada.Containers.Vectors;
package Tampering_Check1_IVectors is new
Ada.Containers.Vectors (Positive, Integer);
procedure Tampering_Check1_Trim
(V : in out Tampering_Check1_IVectors.Vector) is
use Tampering_Check1_IVectors;
begin
while not Is_Empty (V) and then V (V.First) < 0 loop
V.Delete_First;
end loop;
end Tampering_Check1_Trim;
with Tampering_Check1_IVectors;
procedure Tampering_Check1_Trim
(V : in out Tampering_Check1_IVectors.Vector);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment