1--  { dg-do compile }
2
3procedure Iter4 is
4   package Root is
5      type Result is tagged record
6         B : Boolean;
7      end record;
8
9      type T is tagged record
10         I : Integer;
11      end record
12      with Iterable => (First       => Pkg.First, --  { dg-error "primitive operation for Iterable type must appear in the same list of declarations as the type" }
13                        Next        => Pkg.Next,
14                        Has_Element => Pkg.Has_Element,
15                        Element     => Pkg.Element);
16
17      package Pkg is
18         function First (Dummy : T) return Natural is (0);
19         function Next (Dummy : T; Cursor : Natural) return Natural is
20           (Cursor + 1);
21         function Has_Element (Value : T; Cursor : Natural) return Boolean is
22           (Cursor <= Value.I);
23         function Element (Dummy : T; Cursor : Natural) return Result is
24           ((B => Cursor mod 2 = 0));
25      end Pkg;
26   end Root;
27
28   package Derived is
29      type T is new Root.T with record
30         C : Character;
31      end record;
32   end Derived;
33
34begin
35   null;
36end;
37