summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/exit_3.f08
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/gfortran.dg/exit_3.f08
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/gfortran.dg/exit_3.f08')
-rw-r--r--gcc/testsuite/gfortran.dg/exit_3.f0888
1 files changed, 88 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/exit_3.f08 b/gcc/testsuite/gfortran.dg/exit_3.f08
new file mode 100644
index 000000000..732497b6d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/exit_3.f08
@@ -0,0 +1,88 @@
+! { dg-do run }
+! { dg-options "-std=f2008 -fall-intrinsics" }
+
+! PR fortran/44602
+! Check for correct behaviour of EXIT / CYCLE combined with non-loop
+! constructs at run-time.
+
+! Contributed by Daniel Kraft, d@domob.eu.
+
+PROGRAM main
+ IMPLICIT NONE
+
+ TYPE :: t
+ END TYPE t
+
+ INTEGER :: i
+ CLASS(t), ALLOCATABLE :: var
+
+ ! EXIT and CYCLE without names always refer to innermost *loop*. This
+ ! however is checked at run-time already in exit_1.f08.
+
+ ! Basic EXITs from different non-loop constructs.
+
+ i = 2
+ myif: IF (i == 1) THEN
+ CALL abort ()
+ EXIT myif
+ ELSE IF (i == 2) THEN
+ EXIT myif
+ CALL abort ()
+ ELSE
+ CALL abort ()
+ EXIT myif
+ END IF myif
+
+ mysel: SELECT CASE (i)
+ CASE (1)
+ CALL abort ()
+ EXIT mysel
+ CASE (2)
+ EXIT mysel
+ CALL abort ()
+ CASE DEFAULT
+ CALL abort ()
+ EXIT mysel
+ END SELECT mysel
+
+ mycharsel: SELECT CASE ("foobar")
+ CASE ("abc")
+ CALL abort ()
+ EXIT mycharsel
+ CASE ("xyz")
+ CALL abort ()
+ EXIT mycharsel
+ CASE DEFAULT
+ EXIT mycharsel
+ CALL abort ()
+ END SELECT mycharsel
+
+ myblock: BLOCK
+ EXIT myblock
+ CALL abort ()
+ END BLOCK myblock
+
+ myassoc: ASSOCIATE (x => 5 + 2)
+ EXIT myassoc
+ CALL abort ()
+ END ASSOCIATE myassoc
+
+ ALLOCATE (t :: var)
+ mytypesel: SELECT TYPE (var)
+ TYPE IS (t)
+ EXIT mytypesel
+ CALL abort ()
+ CLASS DEFAULT
+ CALL abort ()
+ EXIT mytypesel
+ END SELECT mytypesel
+
+ ! Check EXIT with nested constructs.
+ outer: BLOCK
+ inner: IF (.TRUE.) THEN
+ EXIT outer
+ CALL abort ()
+ END IF inner
+ CALL abort ()
+ END BLOCK outer
+END PROGRAM main