-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly resolve implicit dereferences of access attributes.
- Loading branch information
Showing
7 changed files
with
127 additions
and
13 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
17 changes: 17 additions & 0 deletions
17
testsuite/tests/name_resolution/implicit_deref_2/iterators.adb
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,17 @@ | ||
package body Iterators is | ||
function Consume (I : in Iterator'Class) return Element_Array is | ||
Element : Element_Type; | ||
B : Boolean; | ||
begin | ||
B := I'Unrestricted_Access.Next (Element); | ||
pragma Test_Statement; | ||
I'Unrestricted_Access.Foo; | ||
pragma Test_Statement; | ||
|
||
declare | ||
Result : Element_Array (1 .. 4); | ||
begin | ||
return Result; | ||
end; | ||
end Consume; | ||
end Iterators; |
16 changes: 16 additions & 0 deletions
16
testsuite/tests/name_resolution/implicit_deref_2/iterators.ads
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,16 @@ | ||
generic | ||
type Element_Type is private; | ||
type Element_Array is array (Positive range <>) of Element_Type; | ||
package Iterators is | ||
|
||
type Iterator is interface; | ||
|
||
function Next | ||
(I : in out Iterator; | ||
Element : out Element_Type) return Boolean is abstract; | ||
|
||
procedure Foo (I : access Iterator) is abstract; | ||
|
||
function Consume (I : in Iterator'Class) return Element_Array; | ||
|
||
end Iterators; |
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,65 @@ | ||
Analyzing iterators.adb | ||
####################### | ||
|
||
Resolving xrefs for node <AssignStmt iterators.adb:6:7-6:49> | ||
************************************************************ | ||
|
||
Expr: <Id "B" iterators.adb:6:7-6:8> | ||
references: <DefiningName "B" iterators.adb:4:7-4:8> | ||
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33> | ||
expected type: None | ||
Expr: <CallExpr iterators.adb:6:12-6:48> | ||
references: <DefiningName "Next" iterators.ads:8:13-8:17> | ||
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33> | ||
expected type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33> | ||
Expr: <DottedName iterators.adb:6:12-6:38> | ||
references: <DefiningName "Next" iterators.ads:8:13-8:17> | ||
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33> | ||
expected type: None | ||
Expr: <AttributeRef iterators.adb:6:12-6:33> | ||
references: None | ||
type: <SynthAnonymousTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
expected type: <ConcreteTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
Expr: <Id "I" iterators.adb:6:12-6:13> | ||
references: <DefiningName "I" iterators.adb:2:22-2:23> | ||
type: <ClasswideTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
expected type: <ConcreteTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
Expr: <Id "Unrestricted_Access" iterators.adb:6:14-6:33> | ||
references: None | ||
type: None | ||
expected type: None | ||
Expr: <Id "Next" iterators.adb:6:34-6:38> | ||
references: <DefiningName "Next" iterators.ads:8:13-8:17> | ||
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33> | ||
expected type: None | ||
Expr: <Id "Element" iterators.adb:6:40-6:47> | ||
references: <DefiningName "Element" iterators.adb:3:7-3:14> | ||
type: <FormalTypeDecl ["Element_Type"] iterators.ads:2:4-2:33> | ||
expected type: <FormalTypeDecl ["Element_Type"] iterators.ads:2:4-2:33> | ||
|
||
Resolving xrefs for node <CallStmt iterators.adb:8:7-8:33> | ||
********************************************************** | ||
|
||
Expr: <DottedName iterators.adb:8:7-8:32> | ||
references: <DefiningName "Foo" iterators.ads:12:14-12:17> | ||
type: None | ||
expected type: None | ||
Expr: <AttributeRef iterators.adb:8:7-8:28> | ||
references: None | ||
type: <AnonymousTypeDecl ["None"] iterators.ads:12:23-12:38> | ||
expected type: <AnonymousTypeDecl ["None"] iterators.ads:12:23-12:38> | ||
Expr: <Id "I" iterators.adb:8:7-8:8> | ||
references: <DefiningName "I" iterators.adb:2:22-2:23> | ||
type: <ClasswideTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
expected type: <ConcreteTypeDecl ["Iterator"] iterators.ads:6:4-6:31> | ||
Expr: <Id "Unrestricted_Access" iterators.adb:8:9-8:28> | ||
references: None | ||
type: None | ||
expected type: None | ||
Expr: <Id "Foo" iterators.adb:8:29-8:32> | ||
references: <DefiningName "Foo" iterators.ads:12:14-12:17> | ||
type: None | ||
expected type: None | ||
|
||
|
||
Done. |
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,2 @@ | ||
driver: name-resolution | ||
input_sources: [iterators.adb] |
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,8 @@ | ||
type: bugfix | ||
title: Support implicit dereference of access attributes | ||
description: | | ||
This change fixes a bug where implicit dereferences of access attributes | ||
as in ``X'Unrestricted_Access.Foo (2)`` were not properly resolved, which | ||
could cause property errors to be raised during name resolution. | ||
date: 2023-09-18 | ||
|