Commit fc0e632a by Ed Schonberg Committed by Pierre-Marie de Rodat

[Ada] Unnesting: refactor handling of uplevel refs. for unconstrained arrays

2018-06-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.ads, exp_unst.adb (Needs_Fat_Pointer,
	Build_Access_Type_Decl): New subprograms to handle uplevel references
	to formals of an unconstrained array type. The activation record
	component for these is an access type, and the reference is rewritten
	as an explicit derefenrence of that component.

From-SVN: r261425
parent 65348520
2018-06-11 Ed Schonberg <schonberg@adacore.com>
* exp_unst.ads, exp_unst.adb (Needs_Fat_Pointer,
Build_Access_Type_Decl): New subprograms to handle uplevel references
to formals of an unconstrained array type. The activation record
component for these is an access type, and the reference is rewritten
as an explicit derefenrence of that component.
2018-06-11 Bob Duff <duff@adacore.com> 2018-06-11 Bob Duff <duff@adacore.com>
* libgnat/a-ciorma.adb, libgnat/a-ciormu.adb, libgnat/a-ciorse.adb, * libgnat/a-ciorma.adb, libgnat/a-ciormu.adb, libgnat/a-ciorse.adb,
......
...@@ -562,6 +562,42 @@ package Exp_Unst is ...@@ -562,6 +562,42 @@ package Exp_Unst is
-- uplevel call, a subprogram at level 5 can call one at level 2 or even -- uplevel call, a subprogram at level 5 can call one at level 2 or even
-- the outer level subprogram at level 1. -- the outer level subprogram at level 1.
-------------------------------------
-- Handling of unconstrained types --
-------------------------------------
-- Objects whose nominal subtype is an unconstrained array type present
-- additional complications for translation into LLVM. The address
-- attributes of such objects points to the first component of the
-- array, and the bounds are found elsewhere, typically ahead of the
-- components. In many cases the bounds of an object are stored ahead
-- of the components and can be retrieved from it. However, if the
-- object is an expression (.e.g a slice) the bounds are not adjacent
-- and thus must be conveyed explicitly by means of a so-called
-- fat pointer. This leads to the following enhancements to the
-- handling of uplevel references described so far. This applies only
-- to uplevel references to unconstrained formals of enclosing
-- subprograms:
--
-- a) Uplevel references are detected as before during the tree traversal
-- in Visit_Node. For referenes to uplevel formals, we include those with
-- an unconstrained array type (e.g. String) even if suvh a type has
-- static bounds.
--
-- b) references to unconstrained formals are recognized in the Subp
-- table by means of the predicate Needs_Fat_Pointer.
--
-- c) When constructing the required activation record we also construct
-- a named access type whose designated type is the unconstrained array
-- type. The activation record of a subprogram that contains such an
-- uplevel reference includes a component of this access type. The
-- declaration for that access type is introduced and analyzed before
-- that of the activation record, so it appears in the subprogram that
-- has that formal.
--
-- d) The uplevel reference is rewritten as an explicit dereference (.all)
-- of the corresponding pointer component.
--
----------- -----------
-- Subps -- -- Subps --
----------- -----------
......
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