summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/invalid1.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-20 08:22:38 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-20 08:22:38 +0000
commitccf4f3ae98386198926269817844b5bb67d3ebe4 (patch)
tree15db9a73406c618d2f18f1e9696a3f9549e5ace6 /gcc/testsuite/gnat.dg/invalid1.adb
parent79fb55a1f085a3c03a9168b97773ddd9a4ad054a (diff)
downloadgcc-ccf4f3ae98386198926269817844b5bb67d3ebe4.tar.gz
2011-05-20 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 173935 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@173937 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gnat.dg/invalid1.adb')
-rw-r--r--gcc/testsuite/gnat.dg/invalid1.adb49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/invalid1.adb b/gcc/testsuite/gnat.dg/invalid1.adb
new file mode 100644
index 00000000000..ff9b34ad855
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/invalid1.adb
@@ -0,0 +1,49 @@
+-- { dg-do run }
+-- { dg-options "-gnatws -gnatVa" }
+
+pragma Initialize_Scalars;
+
+procedure Invalid1 is
+
+ X : Boolean;
+ A : Boolean := False;
+
+ procedure Uninit (B : out Boolean) is
+ begin
+ if A then
+ B := True;
+ raise Program_Error;
+ end if;
+ end;
+
+begin
+
+ -- first, check that initialize_scalars is enabled
+ begin
+ if X then
+ A := False;
+ end if;
+ raise Program_Error;
+ exception
+ when Constraint_Error => null;
+ end;
+
+ -- second, check if copyback of an invalid value raises constraint error
+ begin
+ Uninit (A);
+ if A then
+ -- we expect constraint error in the 'if' above according to gnat ug:
+ -- ....
+ -- call. Note that there is no specific option to test `out'
+ -- parameters, but any reference within the subprogram will be tested
+ -- in the usual manner, and if an invalid value is copied back, any
+ -- reference to it will be subject to validity checking.
+ -- ...
+ raise Program_Error;
+ end if;
+ raise Program_Error;
+ exception
+ when Constraint_Error => null;
+ end;
+
+end;