@@ -993,6 +993,34 @@ class renameVisitorClass = object (self)
993993 * variable. Must do its type and attributes. *)
994994 method vvdec (vi : varinfo ) = DoChildren
995995
996+ method vglob (g : global ) : global list visitAction =
997+ match g with
998+ | GVar (v , init , loc ) ->
999+ let update_init glob =
1000+ match glob with
1001+ | GVar (u , uinit , loc ) -> GVar (u, u.vinit, loc)
1002+ | _ -> glob
1003+ in
1004+ let update_all_inits = List. map update_init in
1005+ let () =
1006+ match v.vinit.init, init.init with
1007+ | None , None -> ()
1008+ (* This case may happen when a definition is encountered, but
1009+ the variable was already seen through a declaration and thus
1010+ has no definition *)
1011+ | None , Some (_ ) -> v.vinit.init < - init.init
1012+ (* The following case should never happen because it should never be emitted *)
1013+ | Some (_ ), None -> assert false
1014+ (* The following case is either never emitted (same
1015+ initializations, or different initializations but an error is
1016+ thrown) or emitted when first encountering a definition
1017+ (hence the initializations are supposed to be identical) *)
1018+ | Some (_ ), Some (_ ) -> ()
1019+ in
1020+ ChangeDoChildrenPost ([g], update_all_inits)
1021+ | _ -> DoChildren
1022+
1023+
9961024 (* This is a variable use. See if we must change it *)
9971025 method vvrbl (vi : varinfo ) : varinfo visitAction =
9981026 if not vi.vglob then DoChildren else
0 commit comments