[Ada] Inconsistent scope chain due to quantified expression

Message ID 20180111090253.GA102816@adacore.com
State New
Headers show
Series
  • [Ada] Inconsistent scope chain due to quantified expression
Related show

Commit Message

Pierre-Marie de Rodat Jan. 11, 2018, 9:02 a.m.
This patch corrects the minor decoration performed on invariant procedures in
case the procedure is not inserted into the tree and analyzed. The decoration
now constructs a proper first/next/last entity chain containing the single
formal parameter which represents the object of the related type. The chain
then ensures that any other entities generated by the [pre]analysis of the
invariant expression will be properly added to the chain.

The issue was discovered during the development of the GNATprove tool and
is not visible to end users. No simple test is available because this would
require a debug session.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-01-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_util.adb (Build_Invariant_Procedure_Declaration): Set the last
	entity of the generated invariant procedure in order to construct a
	proper entity chain.

Patch

--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -3466,6 +3466,7 @@  package body Exp_Util is
       Set_Scope (Obj_Id, Proc_Id);
 
       Set_First_Entity (Proc_Id, Obj_Id);
+      Set_Last_Entity  (Proc_Id, Obj_Id);
 
       --  Generate:
       --    procedure <Work_Typ>[Partial_]Invariant (_object : <Obj_Typ>);