| 1 |
-- { dg-do compile } |
| 2 |
|
| 3 |
with Ada.Iterator_Interfaces; |
| 4 |
|
| 5 |
procedure Iter6 is |
| 6 |
package Pkg is |
| 7 |
type Item (<>) is limited private; |
| 8 |
private |
| 9 |
|
| 10 |
type Cursor is null record; |
| 11 |
|
| 12 |
function Constant_Reference (The_Item : aliased Item; |
| 13 |
Unused_Index : Cursor) return String |
| 14 |
is (""); |
| 15 |
|
| 16 |
function Has_More (Data : Cursor) return Boolean is (False); |
| 17 |
|
| 18 |
package List_Iterator_Interfaces is new Ada.Iterator_Interfaces |
| 19 |
(Cursor, Has_More); |
| 20 |
|
| 21 |
function Iterate (The_Item : Item) |
| 22 |
return List_Iterator_Interfaces.Forward_Iterator'class |
| 23 |
is (raise Program_Error); |
| 24 |
|
| 25 |
type Item (Name_Length : Natural) is tagged limited record |
| 26 |
null; |
| 27 |
end record |
| 28 |
with |
| 29 |
Constant_Indexing => Constant_Reference, |
| 30 |
Default_Iterator => Iterate, |
| 31 |
Iterator_Element => String; |
| 32 |
end Pkg; use Pkg; |
| 33 |
|
| 34 |
type Item_Ref is access Item; |
| 35 |
function F return Item_Ref is (null); |
| 36 |
begin |
| 37 |
for I of F.all loop -- { dg-error "cannot iterate over \"Item\"" } |
| 38 |
null; |
| 39 |
end loop; |
| 40 |
end; |