2010-11-11 Jakub Jelinek <jakub@redhat.com>
[official-gcc.git] / gcc / testsuite / gnat.dg / old_errors.adb
bloba5e4d42177f267c92f0af20df8432d8e064fc9c1
1 -- { dg-do compile }
2 package body Old_Errors is
4 A : Integer;
6 function F
7 (X : Integer := A'Old) -- { dg-error "can only appear within subprogram" }
8 return Integer is
9 begin
10 return X;
11 end F;
13 procedure P (I : in Integer; O : out Integer; IO : in out Integer) is
14 Y : Integer := 0;
15 function G
16 (X : Integer := Y'Old) -- { dg-error "cannot refer to local variable" }
17 return Integer is
18 begin
19 return X;
20 end G;
22 function H (X : Integer := A'Old) return Integer is -- OK
23 begin
24 return X;
25 end H;
27 begin
28 Y := Y'Old; -- { dg-error "cannot refer to local variable" }
29 declare
30 Z : Integer := 0;
31 procedure Inner is
32 IL : Integer := 0;
33 begin
34 IL := IL'Old; -- { dg-error "cannot refer to local variable" }
35 Z := Z'Old; -- OK
36 end Inner;
37 begin
38 Y := Z'Old; -- { dg-error "cannot refer to local variable" }
39 end;
40 Y := I'Old; -- { dg-warning "Old applied to constant has no effect" }
41 Y := O'Old; -- OK
42 Y := IO'Old; -- OK
43 Y := G; -- OK, error has been signalled at G declaration
44 pragma Assert (G (3)'Old = Y); -- { dg-error "cannot refer to local variable" }
45 end P;
47 end Old_Errors;