summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/old_errors.adb
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gnat.dg/old_errors.adb
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gnat.dg/old_errors.adb')
-rw-r--r--gcc/testsuite/gnat.dg/old_errors.adb47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/old_errors.adb b/gcc/testsuite/gnat.dg/old_errors.adb
new file mode 100644
index 000000000..a5e4d4217
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/old_errors.adb
@@ -0,0 +1,47 @@
+-- { dg-do compile }
+package body Old_Errors is
+
+ A : Integer;
+
+ function F
+ (X : Integer := A'Old) -- { dg-error "can only appear within subprogram" }
+ return Integer is
+ begin
+ return X;
+ end F;
+
+ procedure P (I : in Integer; O : out Integer; IO : in out Integer) is
+ Y : Integer := 0;
+ function G
+ (X : Integer := Y'Old) -- { dg-error "cannot refer to local variable" }
+ return Integer is
+ begin
+ return X;
+ end G;
+
+ function H (X : Integer := A'Old) return Integer is -- OK
+ begin
+ return X;
+ end H;
+
+ begin
+ Y := Y'Old; -- { dg-error "cannot refer to local variable" }
+ declare
+ Z : Integer := 0;
+ procedure Inner is
+ IL : Integer := 0;
+ begin
+ IL := IL'Old; -- { dg-error "cannot refer to local variable" }
+ Z := Z'Old; -- OK
+ end Inner;
+ begin
+ Y := Z'Old; -- { dg-error "cannot refer to local variable" }
+ end;
+ Y := I'Old; -- { dg-warning "Old applied to constant has no effect" }
+ Y := O'Old; -- OK
+ Y := IO'Old; -- OK
+ Y := G; -- OK, error has been signalled at G declaration
+ pragma Assert (G (3)'Old = Y); -- { dg-error "cannot refer to local variable" }
+ end P;
+
+end Old_Errors;