summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/gomp/appendix-a
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/gomp/appendix-a
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/gomp/appendix-a')
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.1.1.f9010
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.1.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.2.f9016
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.3.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.4.f9016
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.5.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.6.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.7.f9011
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.12.1.f9032
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.13.1.f9016
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.14.1.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.1.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.2.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.3.f9018
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.2.f9020
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.3.f9018
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.1.f9010
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.4.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.5.f9013
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.6.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.1.f9011
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.2.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.3.f9011
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.4.f909
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.5.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f9031
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.25.1.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.26.2.f9023
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.27.1.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.30.1.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.2.f9020
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.3.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.32.1.f9025
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.1.f9011
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.2.f9017
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.4.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.1.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.2.f9022
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f9019
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.2.f9020
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.5.f9013
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f9014
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.36.1.f9023
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.1.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.2.f9013
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.1.f9024
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f9015
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.1.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.2.f9022
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.8.1.f9018
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/appendix-a/a.9.1.f9011
54 files changed, 882 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.1.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.1.1.f90
new file mode 100644
index 000000000..fd83131b5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.1.1.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+ SUBROUTINE A1(N, A, B)
+ INTEGER I, N
+ REAL B(N), A(N)
+!$OMP PARALLEL DO !I is private by default
+ DO I=2,N
+ B(I) = (A(I) + A(I-1)) / 2.0
+ ENDDO
+!$OMP END PARALLEL DO
+ END SUBROUTINE A1
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.1.f90
new file mode 100644
index 000000000..eb8455e19
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.1.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+ SUBROUTINE A11_1(AA, BB, CC, DD, EE, FF, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N), DD(N,N), EE(N,N), FF(N,N)
+!$OMP PARALLEL
+!$OMP WORKSHARE
+ AA = BB
+ CC = DD
+ EE = FF
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_1
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.2.f90
new file mode 100644
index 000000000..11fdc1caa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.2.f90
@@ -0,0 +1,16 @@
+! { do-do compile }
+
+ SUBROUTINE A11_2(AA, BB, CC, DD, EE, FF, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N)
+ REAL DD(N,N), EE(N,N), FF(N,N)
+!$OMP PARALLEL
+!$OMP WORKSHARE
+ AA = BB
+ CC = DD
+!$OMP END WORKSHARE NOWAIT
+!$OMP WORKSHARE
+ EE = FF
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_2
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.3.f90
new file mode 100644
index 000000000..b87232f9c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.3.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+ SUBROUTINE A11_3(AA, BB, CC, DD, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N), DD(N,N)
+ REAL R
+ R=0
+!$OMP PARALLEL
+!$OMP WORKSHARE
+ AA = BB
+!$OMP ATOMIC
+ R = R + SUM(AA)
+ CC = DD
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_3
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.4.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.4.f90
new file mode 100644
index 000000000..ae95c1f98
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.4.f90
@@ -0,0 +1,16 @@
+! { dg-do compile }
+
+ SUBROUTINE A11_4(AA, BB, CC, DD, EE, FF, GG, HH, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N)
+ REAL DD(N,N), EE(N,N), FF(N,N)
+ REAL GG(N,N), HH(N,N)
+!$OMP PARALLEL
+!$OMP WORKSHARE
+ AA = BB
+ CC = DD
+ WHERE (EE .ne. 0) FF = 1 / EE
+ GG = HH
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_4
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.5.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.5.f90
new file mode 100644
index 000000000..6b8e4fa3d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.5.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+ SUBROUTINE A11_5(AA, BB, CC, DD, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N), DD(N,N)
+ INTEGER SHR
+!$OMP PARALLEL SHARED(SHR)
+!$OMP WORKSHARE
+ AA = BB
+ SHR = 1
+ CC = DD * SHR
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_5
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.6.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.6.f90
new file mode 100644
index 000000000..fa31bcffc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.6.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+
+ SUBROUTINE A11_6_WRONG(AA, BB, CC, DD, N)
+ INTEGER N
+ REAL AA(N,N), BB(N,N), CC(N,N), DD(N,N)
+ INTEGER PRI
+!$OMP PARALLEL PRIVATE(PRI)
+!$OMP WORKSHARE
+ AA = BB
+ PRI = 1
+ CC = DD * PRI
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_6_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.7.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.7.f90
new file mode 100644
index 000000000..86b8c7bc5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.11.7.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+ SUBROUTINE A11_7(AA, BB, CC, N)
+ INTEGER N
+ REAL AA(N), BB(N), CC(N)
+!$OMP PARALLEL
+!$OMP WORKSHARE
+ AA(1:50) = BB(11:60)
+ CC(11:20) = AA(1:10)
+!$OMP END WORKSHARE
+!$OMP END PARALLEL
+ END SUBROUTINE A11_7
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.12.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.12.1.f90
new file mode 100644
index 000000000..38389e4f4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.12.1.f90
@@ -0,0 +1,32 @@
+! { dg-do compile }
+ SUBROUTINE A12( X, XOLD, N, TOL )
+ REAL X(*), XOLD(*), TOL
+ INTEGER N
+ INTEGER C, I, TOOBIG
+ REAL ERROR, Y, AVERAGE
+ EXTERNAL AVERAGE
+ C=0
+ TOOBIG = 1
+!$OMP PARALLEL
+ DO WHILE( TOOBIG > 0 )
+!$OMP DO PRIVATE(I)
+ DO I = 2, N-1
+ XOLD(I) = X(I)
+ ENDDO
+!$OMP SINGLE
+ TOOBIG = 0
+!$OMP END SINGLE
+!$OMP DO PRIVATE(I,Y,ERROR), REDUCTION(+:TOOBIG)
+ DO I = 2, N-1
+ Y = X(I)
+ X(I) = AVERAGE( XOLD(I-1), X(I), XOLD(I+1) )
+ ERROR = Y-X(I)
+ IF( ERROR > TOL .OR. ERROR < -TOL ) TOOBIG = TOOBIG+1
+ ENDDO
+!$OMP MASTER
+ C=C+1
+ PRINT *, "Iteration ", C, " TOOBIG=", TOOBIG
+!$OMP END MASTER
+ ENDDO
+!$OMP END PARALLEL
+ END SUBROUTINE A12
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.13.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.13.1.f90
new file mode 100644
index 000000000..57f5b8912
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.13.1.f90
@@ -0,0 +1,16 @@
+! { dg-do compile }
+ SUBROUTINE A13(X, Y)
+ REAL X(*), Y(*)
+ INTEGER IX_NEXT, IY_NEXT
+!$OMP PARALLEL SHARED(X, Y) PRIVATE(IX_NEXT, IY_NEXT)
+!$OMP CRITICAL(XAXIS)
+ CALL DEQUEUE(IX_NEXT, X)
+!$OMP END CRITICAL(XAXIS)
+ CALL WORK(IX_NEXT, X)
+!$OMP CRITICAL(YAXIS)
+ CALL DEQUEUE(IY_NEXT,Y)
+!$OMP END CRITICAL(YAXIS)
+ CALL WORK(IY_NEXT, Y)
+!$OMP END PARALLEL
+ END SUBROUTINE A13
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.14.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.14.1.f90
new file mode 100644
index 000000000..6db107afa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.14.1.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+ SUBROUTINE A14()
+ INTEGER I
+ I=1
+!$OMP PARALLEL SECTIONS
+!$OMP SECTION
+!$OMP CRITICAL (NAME)
+!$OMP PARALLEL
+!$OMP SINGLE
+ I=I+1
+!$OMP END SINGLE
+!$OMP END PARALLEL
+!$OMP END CRITICAL (NAME)
+!$OMP END PARALLEL SECTIONS
+ END SUBROUTINE A14
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.1.f90
new file mode 100644
index 000000000..8fd600176
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.1.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+ SUBROUTINE A17_1_WRONG()
+ INTEGER:: I
+ REAL:: R
+ EQUIVALENCE(I,R)
+!$OMP PARALLEL
+!$OMP ATOMIC
+ I=I+1
+!$OMP ATOMIC
+ R = R + 1.0
+! incorrect because I and R reference the same location
+! but have different types
+!$OMP END PARALLEL
+ END SUBROUTINE A17_1_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.2.f90
new file mode 100644
index 000000000..a19db8c0d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.2.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+
+ SUBROUTINE SUB()
+ COMMON /BLK/ R
+ REAL R
+!$OMP ATOMIC
+ R = R + 1.0
+ END SUBROUTINE SUB
+
+ SUBROUTINE A17_2_WRONG()
+ COMMON /BLK/ I
+ INTEGER I
+!$OMP PARALLEL
+!$OMP ATOMIC
+ I=I+1
+ CALL SUB()
+!$OMP END PARALLEL
+ END SUBROUTINE A17_2_WRONG
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.3.f90
new file mode 100644
index 000000000..4f4f55c09
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.17.3.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+ SUBROUTINE A17_3_WRONG
+ INTEGER:: I
+ REAL:: R
+ EQUIVALENCE(I,R)
+!$OMP PARALLEL
+!$OMP ATOMIC
+ I=I+1
+! incorrect because I and R reference the same location
+! but have different types
+!$OMP END PARALLEL
+!$OMP PARALLEL
+!$OMP ATOMIC
+ R = R + 1.0
+! incorrect because I and R reference the same location
+! but have different types
+!$OMP END PARALLEL
+ END SUBROUTINE A17_3_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.2.f90
new file mode 100644
index 000000000..87359a152
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.2.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+
+ SUBROUTINE WORK(I)
+ INTEGER I
+ END SUBROUTINE WORK
+ SUBROUTINE A21_WRONG(N)
+ INTEGER N
+ INTEGER I
+!$OMP DO ORDERED
+ DO I = 1, N
+! incorrect because an iteration may not execute more than one
+! ordered region
+!$OMP ORDERED
+ CALL WORK(I)
+!$OMP END ORDERED
+!$OMP ORDERED
+ CALL WORK(I+1)
+!$OMP END ORDERED
+ END DO
+ END SUBROUTINE A21_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.3.f90
new file mode 100644
index 000000000..97ca8f458
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.21.3.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+
+ SUBROUTINE A21_GOOD(N)
+ INTEGER N
+!$OMP DO ORDERED
+ DO I = 1,N
+ IF (I <= 10) THEN
+!$OMP ORDERED
+ CALL WORK(I)
+!$OMP END ORDERED
+ ENDIF
+ IF (I > 10) THEN
+!$OMP ORDERED
+ CALL WORK(I+1)
+!$OMP END ORDERED
+ ENDIF
+ ENDDO
+ END SUBROUTINE A21_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.1.f90
new file mode 100644
index 000000000..cc94b1403
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.1.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ INTEGER FUNCTION INCREMENT_COUNTER()
+ COMMON/A22_COMMON/COUNTER
+!$OMP THREADPRIVATE(/A22_COMMON/)
+ COUNTER = COUNTER +1
+ INCREMENT_COUNTER = COUNTER
+ RETURN
+ END FUNCTION INCREMENT_COUNTER
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.4.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.4.f90
new file mode 100644
index 000000000..2a637580b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.4.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ MODULE A22_MODULE
+ COMMON /T/ A
+ END MODULE A22_MODULE
+ SUBROUTINE A22_4_WRONG()
+ USE A22_MODULE
+!$OMP THREADPRIVATE(/T/) ! { dg-error "COMMON block" }
+ !non-conforming because /T/ not declared in A22_4_WRONG
+ END SUBROUTINE A22_4_WRONG
+! { dg-final { cleanup-modules "A22_MODULE" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.5.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.5.f90
new file mode 100644
index 000000000..6531d826c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.5.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ SUBROUTINE A22_5_WRONG()
+ COMMON /T/ A
+!$OMP THREADPRIVATE(/T/)
+ CONTAINS
+ SUBROUTINE A22_5S_WRONG()
+!$OMP PARALLEL COPYIN(/T/) ! { dg-error "COMMON block" }
+ !non-conforming because /T/ not declared in A22_5S_WRONG
+!$OMP END PARALLEL ! { dg-error "Unexpected" }
+ END SUBROUTINE A22_5S_WRONG
+ END SUBROUTINE A22_5_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.6.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.6.f90
new file mode 100644
index 000000000..0a2e6a683
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.22.6.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ SUBROUTINE A22_6_GOOD()
+ COMMON /T/ A
+!$OMP THREADPRIVATE(/T/)
+ CONTAINS
+ SUBROUTINE A22_6S_GOOD()
+ COMMON /T/ A
+!$OMP THREADPRIVATE(/T/)
+!$OMP PARALLEL COPYIN(/T/)
+!$OMP END PARALLEL
+ END SUBROUTINE A22_6S_GOOD
+ END SUBROUTINE A22_6_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.1.f90
new file mode 100644
index 000000000..6eab68729
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.1.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+ SUBROUTINE A23_1_GOOD()
+ COMMON /C/ X,Y
+ REAL X, Y
+!$OMP PARALLEL PRIVATE (/C/)
+ ! do work here
+!$OMP END PARALLEL
+!$OMP PARALLEL SHARED (X,Y)
+ ! do work here
+!$OMP END PARALLEL
+ END SUBROUTINE A23_1_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.2.f90
new file mode 100644
index 000000000..ecfdbe5a2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.2.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+ SUBROUTINE A23_2_GOOD()
+ COMMON /C/ X,Y
+ REAL X, Y
+ INTEGER I
+!$OMP PARALLEL
+!$OMP DO PRIVATE(/C/)
+ DO I=1,1000
+ ! do work here
+ ENDDO
+!$OMP END DO
+!
+!$OMP DO PRIVATE(X)
+ DO I=1,1000
+ ! do work here
+ ENDDO
+!$OMP END DO
+!$OMP END PARALLEL
+ END SUBROUTINE A23_2_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.3.f90
new file mode 100644
index 000000000..abd804102
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.3.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+
+ SUBROUTINE A23_3_GOOD()
+ COMMON /C/ X,Y
+!$OMP PARALLEL PRIVATE (/C/)
+ ! do work here
+!$OMP END PARALLEL
+!$OMP PARALLEL SHARED (/C/)
+ ! do work here
+!$OMP END PARALLEL
+ END SUBROUTINE A23_3_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.4.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.4.f90
new file mode 100644
index 000000000..8c6e2281d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.4.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+ SUBROUTINE A23_4_WRONG()
+ COMMON /C/ X,Y
+! Incorrect because X is a constituent element of C
+!$OMP PARALLEL PRIVATE(/C/), SHARED(X) ! { dg-error "Symbol 'x' present" }
+ ! do work here
+!$OMP END PARALLEL
+ END SUBROUTINE A23_4_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.5.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.5.f90
new file mode 100644
index 000000000..732c15f23
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.23.5.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+
+ SUBROUTINE A23_5_WRONG()
+ COMMON /C/ X,Y
+! Incorrect: common block C cannot be declared both
+! shared and private
+!$OMP PARALLEL PRIVATE (/C/), SHARED(/C/)
+ ! { dg-error "Symbol 'y' present" "" { target *-*-* } 7 }
+ ! { dg-error "Symbol 'x' present" "" { target *-*-* } 7 }
+ ! do work here
+!$OMP END PARALLEL
+ END SUBROUTINE A23_5_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f90
new file mode 100644
index 000000000..e5b95450d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f90
@@ -0,0 +1,31 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ SUBROUTINE A24(A)
+ INTEGER A
+ INTEGER X, Y, Z(1000)
+ INTEGER OMP_GET_NUM_THREADS
+ COMMON/BLOCKX/X
+ COMMON/BLOCKY/Y
+ COMMON/BLOCKZ/Z
+!$OMP THREADPRIVATE(/BLOCKX/)
+ INTEGER I, J
+ i=1
+!$OMP PARALLEL DEFAULT(NONE) PRIVATE(A) SHARED(Z) PRIVATE(J)
+ J = OMP_GET_NUM_THREADS();
+ ! O.K. - J is listed in PRIVATE clause
+ A = Z(J) ! O.K. - A is listed in PRIVATE clause
+ ! - Z is listed in SHARED clause
+ X=1 ! O.K. - X is THREADPRIVATE
+ Z(I) = Y ! Error - cannot reference I or Y here
+! { dg-error "'i' not specified" "" { target *-*-* } 20 } */
+! { dg-error "enclosing parallel" "" { target *-*-* } 14 } */
+! { dg-error "'y' not specified" "" { target *-*-* } 20 } */
+!$OMP DO firstprivate(y)
+ DO I = 1,10
+ Z(I) = Y ! O.K. - I is the loop iteration variable
+ ! Y is listed in FIRSTPRIVATE clause
+ END DO
+ Z(I) = Y ! Error - cannot reference I or Y here
+!$OMP END PARALLEL
+ END SUBROUTINE A24
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.25.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.25.1.f90
new file mode 100644
index 000000000..66bfba80e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.25.1.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+
+ SUBROUTINE A25
+ INTEGER OMP_GET_THREAD_NUM
+ REAL A(20)
+ INTEGER MYTHREAD
+ !$OMP PARALLEL SHARED(A) PRIVATE(MYTHREAD)
+ MYTHREAD = OMP_GET_THREAD_NUM()
+ IF (MYTHREAD .EQ. 0) THEN
+ CALL SUB(A(1:10)) ! compiler may introduce writes to A(6:10)
+ ELSE
+ A(6:10) = 12
+ ENDIF
+ !$OMP END PARALLEL
+ END SUBROUTINE A25
+ SUBROUTINE SUB(X)
+ REAL X(*)
+ X(1:5) = 4
+ END SUBROUTINE SUB
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.26.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.26.2.f90
new file mode 100644
index 000000000..3d43424b6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.26.2.f90
@@ -0,0 +1,23 @@
+! { dg-do compile }
+
+ MODULE A26_2
+ REAL A
+ CONTAINS
+ SUBROUTINE G(K)
+ REAL K
+ A = K ! This is A in module A26_2, not the private
+ ! A in F
+ END SUBROUTINE G
+ SUBROUTINE F(N)
+ INTEGER N
+ REAL A
+ INTEGER I
+!$OMP PARALLEL DO PRIVATE(A)
+ DO I = 1,N
+ A=I
+ CALL G(A*2)
+ ENDDO
+!$OMP END PARALLEL DO
+ END SUBROUTINE F
+ END MODULE A26_2
+! { dg-final { cleanup-modules "A26_2" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.27.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.27.1.f90
new file mode 100644
index 000000000..f564bd380
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.27.1.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+
+ SUBROUTINE A27()
+ INTEGER I, A
+!$OMP PARALLEL PRIVATE(A)
+!$OMP PARALLEL DO PRIVATE(A)
+ DO I = 1, 10
+ ! do work here
+ END DO
+!$OMP END PARALLEL DO
+!$OMP END PARALLEL
+ END SUBROUTINE A27
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.30.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.30.1.f90
new file mode 100644
index 000000000..e62cbf81b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.30.1.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+
+ SUBROUTINE A30(N, A, B)
+ INTEGER N
+ REAL A(*), B(*)
+ INTEGER I
+!$OMP PARALLEL
+!$OMP DO LASTPRIVATE(I)
+ DO I=1,N-1
+ A(I) = B(I) + B(I+1)
+ ENDDO
+!$OMP END PARALLEL
+ A(I) = B(I) ! I has the value of N here
+ END SUBROUTINE A30
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90
new file mode 100644
index 000000000..7459897eb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+
+ SUBROUTINE A31_1(A, B, X, Y, N)
+ INTEGER N
+ REAL X(*), Y(*), A, B
+!$OMP PARALLEL DO PRIVATE(I) SHARED(X, N) REDUCTION(+:A) &
+!$OMP& REDUCTION(MIN:B)
+ DO I=1,N
+ A = A + X(I)
+ B = MIN(B, Y(I))
+! Note that some reductions can be expressed in
+! other forms. For example, the MIN could be expressed as
+! IF (B > Y(I)) B = Y(I)
+ END DO
+ END SUBROUTINE A31_1
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.2.f90
new file mode 100644
index 000000000..f78188c7c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.2.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+
+ SUBROUTINE A31_2 (A, B, X, Y, N)
+ INTEGER N
+ REAL X(*), Y(*), A, B, A_P, B_P
+!$OMP PARALLEL SHARED(X, Y, N, A, B) PRIVATE(A_P, B_P)
+ A_P = 0.0
+ B_P = HUGE(B_P)
+!$OMP DO PRIVATE(I)
+ DO I=1,N
+ A_P = A_P + X(I)
+ B_P = MIN(B_P, Y(I))
+ ENDDO
+!$OMP END DO
+!$OMP CRITICAL
+ A = A + A_P
+ B = MIN(B, B_P)
+!$OMP END CRITICAL
+!$OMP END PARALLEL
+ END SUBROUTINE A31_2
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.3.f90
new file mode 100644
index 000000000..f67c91c21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.3.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+ PROGRAM A31_3_WRONG
+ MAX = HUGE(0)
+ M=0
+ !$OMP PARALLEL DO REDUCTION(MAX: M) ! MAX is no longer the
+ ! intrinsic so this
+ ! is non-conforming
+! { dg-error "is not INTRINSIC procedure name" "" { target *-*-* } 5 } */
+ DO I = 1, 100
+ CALL SUB(M,I)
+ END DO
+ END PROGRAM A31_3_WRONG
+ SUBROUTINE SUB(M,I)
+ M = MAX(M,I)
+ END SUBROUTINE SUB
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.32.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.32.1.f90
new file mode 100644
index 000000000..498a6d324
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.32.1.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ MODULE M
+ REAL, POINTER, SAVE :: WORK(:)
+ INTEGER :: SIZE
+ REAL :: TOL
+!$OMP THREADPRIVATE(WORK,SIZE,TOL)
+ END MODULE M
+ SUBROUTINE A32( T, N )
+ USE M
+ REAL :: T
+ INTEGER :: N
+ TOL = T
+ SIZE = N
+!$OMP PARALLEL COPYIN(TOL,SIZE)
+ CALL BUILD
+!$OMP END PARALLEL
+ END SUBROUTINE A32
+ SUBROUTINE BUILD
+ USE M
+ ALLOCATE(WORK(SIZE))
+ WORK = TOL
+ END SUBROUTINE BUILD
+! { dg-final { cleanup-modules "M" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.1.f90
new file mode 100644
index 000000000..05145b171
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.1.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-require-effective-target tls }
+
+ SUBROUTINE INIT(A,B)
+ REAL A, B
+ COMMON /XY/ X,Y
+!$OMP THREADPRIVATE (/XY/)
+!$OMP SINGLE
+ READ (11) A,B,X,Y
+!$OMP END SINGLE COPYPRIVATE (A,B,/XY/)
+ END SUBROUTINE INIT
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.2.f90
new file mode 100644
index 000000000..ced23c856
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.2.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+
+ REAL FUNCTION READ_NEXT()
+ REAL, POINTER :: TMP
+!$OMP SINGLE
+ ALLOCATE (TMP)
+!$OMP END SINGLE COPYPRIVATE (TMP) ! copies the pointer only
+!$OMP MASTER
+ READ (11) TMP
+!$OMP END MASTER
+!$OMP BARRIER
+ READ_NEXT = TMP
+!$OMP BARRIER
+!$OMP SINGLE
+ DEALLOCATE (TMP)
+!$OMP END SINGLE NOWAIT
+ END FUNCTION READ_NEXT
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.4.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.4.f90
new file mode 100644
index 000000000..7a9e1840b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.33.4.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+ SUBROUTINE S(N)
+ INTEGER N
+ REAL, DIMENSION(:), ALLOCATABLE :: A
+ REAL, DIMENSION(:), POINTER :: B
+ ALLOCATE (A(N))
+!$OMP SINGLE
+ ALLOCATE (B(N))
+ READ (11) A,B
+!$OMP END SINGLE COPYPRIVATE(A,B)
+ ! Variable A designates a private object
+ ! which has the same value in each thread
+ ! Variable B designates a shared object
+!$OMP BARRIER
+!$OMP SINGLE
+ DEALLOCATE (B)
+!$OMP END SINGLE NOWAIT
+ END SUBROUTINE S
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.1.f90
new file mode 100644
index 000000000..29ea952cb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.1.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+ SUBROUTINE WORK(I, J)
+ INTEGER I, J
+ END SUBROUTINE WORK
+ SUBROUTINE GOOD_NESTING(N)
+ INTEGER N
+ INTEGER I
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+!$OMP PARALLEL SHARED(I,N)
+!$OMP DO
+ DO J = 1, N
+ CALL WORK(I,J)
+ END DO
+!$OMP END PARALLEL
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE GOOD_NESTING
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.2.f90
new file mode 100644
index 000000000..980a62372
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.34.2.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+ SUBROUTINE WORK(I, J)
+ INTEGER I, J
+ END SUBROUTINE WORK
+ SUBROUTINE WORK1(I, N)
+ INTEGER J
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO J = 1, N
+ CALL WORK(I,J)
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE WORK1
+ SUBROUTINE GOOD_NESTING2(N)
+ INTEGER N
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+ CALL WORK1(I, N)
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE GOOD_NESTING2
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90
new file mode 100644
index 000000000..7431a6579
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+
+ SUBROUTINE WORK(I, J)
+ INTEGER I, J
+ END SUBROUTINE WORK
+ SUBROUTINE WRONG1(N)
+ INTEGER N
+ INTEGER I,J
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+ ! incorrect nesting of loop regions
+!$OMP DO ! { dg-warning "may not be closely nested" }
+ DO J = 1, N
+ CALL WORK(I,J)
+ END DO
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG1
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.2.f90
new file mode 100644
index 000000000..5fad2c05f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.2.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+
+ SUBROUTINE WORK1(I,N)
+ INTEGER I, N
+ INTEGER J
+!$OMP DO ! incorrect nesting of loop regions
+ DO J = 1, N
+ CALL WORK(I,J)
+ END DO
+ END SUBROUTINE WORK1
+ SUBROUTINE WRONG2(N)
+ INTEGER N
+ INTEGER I
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+ CALL WORK1(I,N)
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG2
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90
new file mode 100644
index 000000000..bb3e02fef
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+
+ SUBROUTINE WRONG3(N)
+ INTEGER N
+ INTEGER I
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+ ! incorrect nesting of regions
+!$OMP SINGLE ! { dg-warning "may not be closely nested" }
+ CALL WORK(I, 1)
+!$OMP END SINGLE
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG3
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f90
new file mode 100644
index 000000000..f130dd5f4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+
+ SUBROUTINE WRONG4(N)
+ INTEGER N
+ INTEGER I
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP DO
+ DO I = 1, N
+ CALL WORK(I, 1)
+! incorrect nesting of barrier region in a loop region
+!$OMP BARRIER ! { dg-warning "may not be closely nested" }
+ CALL WORK(I, 2)
+ END DO
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG4
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.5.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.5.f90
new file mode 100644
index 000000000..083c0b3b7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.5.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+
+ SUBROUTINE WRONG5(N)
+ INTEGER N
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP CRITICAL
+ CALL WORK(N,1)
+! incorrect nesting of barrier region in a critical region
+!$OMP BARRIER
+ CALL WORK(N,2)
+!$OMP END CRITICAL
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG5
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f90
new file mode 100644
index 000000000..62ba24523
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+
+ SUBROUTINE WRONG6(N)
+ INTEGER N
+!$OMP PARALLEL DEFAULT(SHARED)
+!$OMP SINGLE
+ CALL WORK(N,1)
+! incorrect nesting of barrier region in a single region
+!$OMP BARRIER ! { dg-warning "may not be closely nested" }
+ CALL WORK(N,2)
+!$OMP END SINGLE
+!$OMP END PARALLEL
+ END SUBROUTINE WRONG6
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.36.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.36.1.f90
new file mode 100644
index 000000000..be68188ec
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.36.1.f90
@@ -0,0 +1,23 @@
+! { dg-do compile }
+
+ SUBROUTINE DO_BY_16(X, IAM, IPOINTS)
+ REAL X(*)
+ INTEGER IAM, IPOINTS
+ END SUBROUTINE DO_BY_16
+ SUBROUTINE SUBA36(X, NPOINTS)
+ INTEGER NPOINTS
+ REAL X(NPOINTS)
+ INTEGER IAM, IPOINTS
+ EXTERNAL OMP_SET_DYNAMIC, OMP_SET_NUM_THREADS
+ INTEGER OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM
+ CALL OMP_SET_DYNAMIC(.FALSE.)
+ CALL OMP_SET_NUM_THREADS(16)
+!$OMP PARALLEL SHARED(X,NPOINTS) PRIVATE(IAM, IPOINTS)
+ IF (OMP_GET_NUM_THREADS() .NE. 16) THEN
+ STOP
+ ENDIF
+ IAM = OMP_GET_THREAD_NUM()
+ IPOINTS = NPOINTS/16
+ CALL DO_BY_16(X,IAM,IPOINTS)
+!$OMP END PARALLEL
+ END SUBROUTINE SUBA36
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.1.f90
new file mode 100644
index 000000000..473c1fec8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.1.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+ SUBROUTINE WORK(I)
+ INTEGER I
+ I=I+1
+ END SUBROUTINE WORK
+ SUBROUTINE INCORRECT()
+ INTEGER OMP_GET_NUM_THREADS
+ INTEGER I, NP
+ NP = OMP_GET_NUM_THREADS() !misplaced: will return 1
+!$OMP PARALLEL DO SCHEDULE(STATIC)
+ DO I = 0, NP-1
+ CALL WORK(I)
+ ENDDO
+!$OMP END PARALLEL DO
+ END SUBROUTINE INCORRECT
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.2.f90
new file mode 100644
index 000000000..c5fbcbbd0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.37.2.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+ SUBROUTINE WORK(I)
+ INTEGER I
+ I=I+1
+ END SUBROUTINE WORK
+ SUBROUTINE CORRECT()
+ INTEGER OMP_GET_THREAD_NUM
+ INTEGER I
+!$OMP PARALLEL PRIVATE(I)
+ I = OMP_GET_THREAD_NUM()
+ CALL WORK(I)
+!$OMP END PARALLEL
+ END SUBROUTINE CORRECT
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.1.f90
new file mode 100644
index 000000000..f1c6c6596
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.1.f90
@@ -0,0 +1,24 @@
+! { dg-do compile }
+
+ SUBROUTINE WORK(I, J)
+ INTEGER I,J
+ END SUBROUTINE WORK
+ SUBROUTINE A6_GOOD()
+ INTEGER I, J
+ REAL A(1000)
+ DO 100 I = 1,10
+!$OMP DO
+ DO 100 J = 1,10
+ CALL WORK(I,J)
+ 100 CONTINUE ! !$OMP ENDDO implied here
+!$OMP DO
+ DO 200 J = 1,10
+200 A(I) = I + 1
+!$OMP ENDDO
+!$OMP DO
+ DO 300 I = 1,10
+ DO 300 J = 1,10
+ CALL WORK(I,J)
+300 CONTINUE
+!$OMP ENDDO
+ END SUBROUTINE A6_GOOD
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f90
new file mode 100644
index 000000000..e13880899
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+
+ SUBROUTINE WORK(I, J)
+ INTEGER I,J
+ END SUBROUTINE WORK
+
+ SUBROUTINE A6_WRONG
+ INTEGER I, J
+ DO 100 I = 1,10
+!$OMP DO
+ DO 100 J = 1,10
+ CALL WORK(I,J)
+ 100 CONTINUE
+!$OMP ENDDO ! { dg-error "Unexpected ..OMP END DO statement" }
+ END SUBROUTINE A6_WRONG
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.1.f90
new file mode 100644
index 000000000..9f3b08d2e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.1.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+SUBROUTINE A7_1(A,N)
+INTEGER OMP_GET_THREAD_NUM
+REAL A(*)
+INTEGER I, MYOFFSET, N
+!$OMP PARALLEL PRIVATE(MYOFFSET)
+ MYOFFSET = OMP_GET_THREAD_NUM()*N
+ DO I = 1, N
+ A(MYOFFSET+I) = FLOAT(I)
+ ENDDO
+!$OMP END PARALLEL
+END SUBROUTINE A7_1
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.2.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.2.f90
new file mode 100644
index 000000000..23f231876
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.7.2.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+
+SUBROUTINE A7_2(A,B,N,I1,I2)
+REAL A(*), B(*)
+INTEGER I1, I2, N
+!$OMP PARALLEL SHARED(A,B,I1,I2)
+!$OMP SECTIONS
+!$OMP SECTION
+ DO I1 = I1, N
+ IF (A(I1).NE.0.0) EXIT
+ ENDDO
+!$OMP SECTION
+ DO I2 = I2, N
+ IF (B(I2).NE.0.0) EXIT
+ ENDDO
+!$OMP END SECTIONS
+!$OMP SINGLE
+ IF (I1.LE.N) PRINT *, "ITEMS IN A UP TO ", I1, " ARE ALL ZERO."
+ IF (I2.LE.N) PRINT *, "ITEMS IN B UP TO ", I2, " ARE ALL ZERO."
+!$OMP END SINGLE
+!$OMP END PARALLEL
+END SUBROUTINE A7_2
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.8.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.8.1.f90
new file mode 100644
index 000000000..f499e7f89
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.8.1.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+ SUBROUTINE A8(N, M, A, B, Y, Z)
+ INTEGER N, M
+ REAL A(*), B(*), Y(*), Z(*)
+ INTEGER I
+!$OMP PARALLEL
+!$OMP DO
+ DO I=2,N
+ B(I) = (A(I) + A(I-1)) / 2.0
+ ENDDO
+!$OMP END DO NOWAIT
+!$OMP DO
+ DO I=1,M
+ Y(I) = SQRT(Z(I))
+ ENDDO
+!$OMP END DO NOWAIT
+!$OMP END PARALLEL
+ END SUBROUTINE A8
diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.9.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.9.1.f90
new file mode 100644
index 000000000..fc7b67de5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.9.1.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+ SUBROUTINE A9()
+!$OMP PARALLEL SECTIONS
+!$OMP SECTION
+ CALL XAXIS()
+!$OMP SECTION
+ CALL YAXIS()
+!$OMP SECTION
+ CALL ZAXIS()
+!$OMP END PARALLEL SECTIONS
+ END SUBROUTINE A9