diff mbox series

[Ada] Adapt new extended traversal of AST to have optional part

Message ID 20190812090250.GA22574@adacore.com
State New
Headers show
Series [Ada] Adapt new extended traversal of AST to have optional part | expand

Commit Message

Pierre-Marie de Rodat Aug. 12, 2019, 9:02 a.m. UTC
The new extended traversal of the AST for GNATprove use now optionally
traverses the ranges under Itypes, based on a formal parameter.

There is no impact on compilation.

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

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

gcc/ada/

	* sem_util.adb, sem_util.ads (Traverse_More_Func,
	Traverse_More_Proc): Add formal parameter for Itypes traversal.
diff mbox series

Patch

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -25565,11 +25565,13 @@  package body Sem_Util is
                null;
          end case;
 
-         --  Then process unattached nodes which come from Itypes. This only
-         --  concerns currently ranges of scalar (possibly as index) types.
-         --  This traversal is protected against looping with Processing_Itype.
+         --  If Process_Itypes is True, process unattached nodes which come
+         --  from Itypes. This only concerns currently ranges of scalar
+         --  (possibly as index) types. This traversal is protected against
+         --  looping with Processing_Itype.
 
-         if not Processing_Itype
+         if Process_Itypes
+           and then not Processing_Itype
            and then Nkind (Node) in N_Has_Etype
            and then Present (Etype (Node))
            and then Is_Itype (Etype (Node))
@@ -25628,7 +25630,7 @@  package body Sem_Util is
    ------------------------
 
    procedure Traverse_More_Proc (Node : Node_Id) is
-      function Traverse is new Traverse_More_Func (Process);
+      function Traverse is new Traverse_More_Func (Process, Process_Itypes);
       Discard : Traverse_Final_Result;
       pragma Warnings (Off, Discard);
    begin

--- gcc/ada/sem_util.ads
+++ gcc/ada/sem_util.ads
@@ -2814,14 +2814,17 @@  package Sem_Util is
 
    generic
       with function Process (N : Node_Id) return Traverse_Result is <>;
+      Process_Itypes : Boolean := False;
    function Traverse_More_Func (Node : Node_Id) return Traverse_Final_Result;
    --  This is a version of Atree.Traverse_Func that not only traverses
    --  syntactic children of nodes, but also semantic children which are
    --  logically children of the node. This concerns currently lists of
    --  action nodes and ranges under Itypes, both inserted by the compiler.
+   --  Itypes are only traversed when Process_Itypes is True.
 
    generic
       with function Process (N : Node_Id) return Traverse_Result is <>;
+      Process_Itypes : Boolean := False;
    procedure Traverse_More_Proc (Node : Node_Id);
    pragma Inline (Traverse_More_Proc);
    --  This is the same as Traverse_More_Func except that no result is