diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-06-01 14:21:38 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-06-01 14:21:38 +0200 |
commit | 3e32893c0bba66df33a1143afcb45e345172360a (patch) | |
tree | 3dfc018192a37399a5ca433cddee738e5cd60c81 /gcc | |
parent | 8c38360082278de6400ac277e15f75edecc8eb39 (diff) | |
download | gcc-3e32893c0bba66df33a1143afcb45e345172360a.zip gcc-3e32893c0bba66df33a1143afcb45e345172360a.tar.gz gcc-3e32893c0bba66df33a1143afcb45e345172360a.tar.bz2 |
parse.c (case_decl): Move ST_OMP_* to ...
* parse.c (case_decl): Move ST_OMP_* to ...
(case_omp_decl): ... here, new macro.
(verify_st_order): For case_omp_decl, complain about
p->state >= ORDER_EXEC, but don't change p->state otherwise.
* gfortran.dg/gomp/order-1.f90: New test.
* gfortran.dg/gomp/order-2.f90: New test.
From-SVN: r236987
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/order-1.f90 | 92 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/order-2.f90 | 37 |
5 files changed, 157 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 73235c6..8cff148 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-06-01 Jakub Jelinek <jakub@redhat.com> + + * parse.c (case_decl): Move ST_OMP_* to ... + (case_omp_decl): ... here, new macro. + (verify_st_order): For case_omp_decl, complain about + p->state >= ORDER_EXEC, but don't change p->state otherwise. + 2016-05-26 Jakub Jelinek <jakub@redhat.com> * openmp.c (resolve_omp_clauses): Warn if chunk_size is known not to diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index dd7aa6a..1081b2e 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1390,9 +1390,13 @@ next_statement (void) #define case_decl case ST_ATTR_DECL: case ST_COMMON: case ST_DATA_DECL: \ case ST_EQUIVALENCE: case ST_NAMELIST: case ST_STATEMENT_FUNCTION: \ - case ST_TYPE: case ST_INTERFACE: case ST_OMP_THREADPRIVATE: \ - case ST_PROCEDURE: case ST_OMP_DECLARE_SIMD: case ST_OMP_DECLARE_REDUCTION: \ - case ST_OMP_DECLARE_TARGET: case ST_OACC_ROUTINE: case ST_OACC_DECLARE + case ST_TYPE: case ST_INTERFACE: case ST_PROCEDURE: case ST_OACC_ROUTINE: \ + case ST_OACC_DECLARE + +/* OpenMP declaration statements. */ + +#define case_omp_decl case ST_OMP_THREADPRIVATE: case ST_OMP_DECLARE_SIMD: \ + case ST_OMP_DECLARE_TARGET: case ST_OMP_DECLARE_REDUCTION /* Block end statements. Errors associated with interchanging these are detected in gfc_match_end(). */ @@ -2488,6 +2492,14 @@ verify_st_order (st_state *p, gfc_statement st, bool silent) p->state = ORDER_SPEC; break; + case_omp_decl: + /* The OpenMP directives have to be somewhere in the specification + part, but there are no further requirements on their ordering. + Thus don't adjust p->state, just ignore them. */ + if (p->state >= ORDER_EXEC) + goto order; + break; + case_executable: case_exec_markers: if (p->state < ORDER_EXEC) @@ -3563,6 +3575,7 @@ loop: case ST_STRUCTURE_DECL: case ST_DERIVED_DECL: case_decl: + case_omp_decl: declSt: if (!verify_st_order (&ss, st, false)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75d8504..1efe0e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-01 Jakub Jelinek <jakub@redhat.com> + + * gfortran.dg/gomp/order-1.f90: New test. + * gfortran.dg/gomp/order-2.f90: New test. + 2016-06-01 Jan Hubicka <hubicka@ucw.cz> * gcc.dg/unroll-6.c: Update template. diff --git a/gcc/testsuite/gfortran.dg/gomp/order-1.f90 b/gcc/testsuite/gfortran.dg/gomp/order-1.f90 new file mode 100644 index 0000000..23db74c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/order-1.f90 @@ -0,0 +1,92 @@ +! { dg-do compile } + +module m + integer :: i +end module m +subroutine f1 + type t + integer :: i + end type t + interface + integer function f3 (a, b) + !$omp declare simd (f3) uniform (a) + use m + import :: t + implicit none + type (t) :: a + integer :: b + end function f3 + end interface + interface + integer function f4 (a, b) + use m + !$omp declare simd (f4) uniform (a) + import :: t + implicit none + type (t) :: a + integer :: b + end function f4 + end interface + interface + integer function f5 (a, b) + use m + import :: t + !$omp declare simd (f5) uniform (a) + implicit none + type (t) :: a + integer :: b + end function f5 + end interface + interface + integer function f6 (a, b) + use m + import :: t + implicit none + !$omp declare simd (f6) uniform (a) + type (t) :: a + integer :: b + end function f6 + end interface + interface + integer function f7 (a, b) + use m + import :: t + implicit none + type (t) :: a + !$omp declare simd (f7) uniform (a) + integer :: b + end function f7 + end interface + call f2 +contains + subroutine f2 + !$omp threadprivate (t1) + use m + !$omp threadprivate (t2) + implicit none + !$omp threadprivate (t3) + integer, save :: t1, t2, t3, t4 + !$omp threadprivate (t4) + t1 = 1; t2 = 2; t3 = 3; t4 = 4 + end subroutine f2 + subroutine f8 + !$omp declare reduction (f8_1:real:omp_out = omp_out + omp_in) + use m + !$omp declare reduction (f8_2:real:omp_out = omp_out + omp_in) + implicit none + !$omp declare reduction (f8_3:real:omp_out = omp_out + omp_in) + integer :: j + !$omp declare reduction (f8_4:real:omp_out = omp_out + omp_in) + end subroutine f8 + subroutine f9 + !$omp declare target (f9_1) + use m + !$omp declare target (f9_2) + implicit none + !$omp declare target (f9_3) + !$omp declare target + integer, save :: f9_1, f9_2, f9_3, f9_4 + !$omp declare target (f9_4) + f9_1 = 1; f9_2 = 2; f9_3 = 3; f9_4 = 4 + end subroutine f9 +end subroutine f1 diff --git a/gcc/testsuite/gfortran.dg/gomp/order-2.f90 b/gcc/testsuite/gfortran.dg/gomp/order-2.f90 new file mode 100644 index 0000000..4ee3a82 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/order-2.f90 @@ -0,0 +1,37 @@ +! { dg-do compile } + +module m + integer :: i +end module m +subroutine f1 + call f2 +contains + subroutine f2 + use m + implicit none + integer, save :: t + t = 1 + !$omp threadprivate (t1) ! { dg-error "Unexpected" } + end subroutine f2 + subroutine f3 + use m + implicit none + integer :: j + j = 1 + !$omp declare reduction (foo:real:omp_out = omp_out + omp_in) ! { dg-error "Unexpected" } + end subroutine f3 + subroutine f4 + use m + implicit none + !$omp declare target + integer, save :: f4_1 + f4_1 = 1 + !$omp declare target (f4_1) ! { dg-error "Unexpected" } + !$omp declare target ! { dg-error "Unexpected" } + end subroutine f4 + integer function f5 (a, b) + integer :: a, b + a = 1; b = 2 + !$omp declare simd (f5) notinbranch ! { dg-error "Unexpected" } + end function f5 +end subroutine f1 |