-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/1266' into 'master'
Improve iterator/indexing types and Implicit_Dereference aspect support Closes #1266 See merge request eng/libadalang/libadalang!1548
- Loading branch information
Showing
4 changed files
with
329 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
procedure Test is | ||
|
||
package P is | ||
type T is tagged null record; | ||
type T_Element is access all T; | ||
|
||
function Key (This : in T) return Integer is (1); | ||
|
||
type T_Constant_Reference (Element : access constant T_Element) is private | ||
with Implicit_Dereference => Element; | ||
|
||
type MyArr (Capacity : Integer) is tagged private | ||
with Constant_Indexing => Query, | ||
Iterator_Element => T_Element; | ||
|
||
type Elems_Access is access all MyArr; | ||
|
||
function Query(This: MyArr; Index : Integer) return T_Constant_Reference; | ||
private | ||
type T_Constant_Reference | ||
(Element : access constant T_Element) is null record; | ||
type MyArr (Capacity : Integer) is tagged null record; | ||
end P; | ||
|
||
package body P is | ||
function Query | ||
(This: MyArr; Index : Integer) return T_Constant_Reference is | ||
(T_Constant_Reference'(Element => null)); | ||
|
||
procedure X (Elems : Elems_Access) is | ||
T : T_Element := Elems.all (1); | ||
pragma Test_Statement; | ||
C : T_Constant_Reference := Elems.all (1); | ||
pragma Test_Statement; | ||
I : Integer := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
begin | ||
I := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
end X; | ||
end P; | ||
|
||
use P; | ||
|
||
procedure Y (Elems : Elems_Access) is | ||
T : T_Element := Elems.all (1); | ||
pragma Test_Statement; | ||
C : T_Constant_Reference := Elems.all (1); | ||
pragma Test_Statement; | ||
I : Integer := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
begin | ||
I := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
end Y; | ||
|
||
begin | ||
null; | ||
end Test; |
Oops, something went wrong.