From 9fa6cfec03275391d93cf67e1691f11c053f1220 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 22 Sep 2007 16:20:57 +0200 Subject: [PATCH] re PR fortran/33445 (Diagnose "!$OMP&" as an error in free format unless it is a continuation line) 2007-09-22 Tobias Burnus PR fortran/33445 * scanner.c (skip_free_comments): Warn if !$OMP& is used if no OpenMP directive is to be continued. 2007-09-22 Tobias Burnus PR fortran/33445 * gfortran.dg/gomp/free-2.f90: New. * gfortran.dg/gomp/appendix-a/a.31.1.f90: Add missing &. * gfortran.dg/gomp/omp_parse1.f90: Add dg-warning. From-SVN: r128670 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/scanner.c | 25 ++++++++++++------- gcc/testsuite/ChangeLog | 7 ++++++ .../gfortran.dg/gomp/appendix-a/a.31.1.f90 | 2 +- gcc/testsuite/gfortran.dg/gomp/free-2.f90 | 14 +++++++++++ gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 | 2 +- 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/free-2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 586c71919eb..f683ea3c7f6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-09-22 Tobias Burnus + + PR fortran/33445 + * scanner.c (skip_free_comments): Warn if !$OMP& is used + if no OpenMP directive is to be continued. + 2007-09-21 Paul Thomas *trans-expr.c (gfc_trans_pointer_assignment): Convert array diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index b0c7979554e..fe7d213ae0b 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -417,18 +417,25 @@ skip_free_comments (void) if (c == 'o' || c == 'O') { if (((c = next_char ()) == 'm' || c == 'M') - && ((c = next_char ()) == 'p' || c == 'P') - && ((c = next_char ()) == ' ' || continue_flag)) + && ((c = next_char ()) == 'p' || c == 'P')) { - while (gfc_is_whitespace (c)) - c = next_char (); - if (c != '\n' && c != '!') + if ((c = next_char ()) == ' ' || continue_flag) { - openmp_flag = 1; - openmp_locus = old_loc; - gfc_current_locus = start; - return false; + while (gfc_is_whitespace (c)) + c = next_char (); + if (c != '\n' && c != '!') + { + openmp_flag = 1; + openmp_locus = old_loc; + gfc_current_locus = start; + return false; + } } + else + gfc_warning_now ("!$OMP at %C starts a commented " + "line as it neither is followed " + "by a space nor is a " + "continuation line"); } gfc_current_locus = old_loc; next_char (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0b3c194e5c0..96387b225d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-09-22 Tobias Burnus + + PR fortran/33445 + * gfortran.dg/gomp/free-2.f90: New. + * gfortran.dg/gomp/appendix-a/a.31.1.f90: Add missing &. + * gfortran.dg/gomp/omp_parse1.f90: Add dg-warning. + 2007-09-22 Uros Bizjak * gcc.target/i386/sse5-hadduX.c: Remove target selector. 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 index 294926bfdca..7459897ebbd 100644 --- a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90 @@ -3,7 +3,7 @@ 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 PARALLEL DO PRIVATE(I) SHARED(X, N) REDUCTION(+:A) & !$OMP& REDUCTION(MIN:B) DO I=1,N A = A + X(I) diff --git a/gcc/testsuite/gfortran.dg/gomp/free-2.f90 b/gcc/testsuite/gfortran.dg/gomp/free-2.f90 new file mode 100644 index 00000000000..60bac66b849 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/free-2.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! +! PR fortran/33445 +! +!$OMP&foo ! { dg-warning "starts a commented line" } +! +!$OMP parallel +!$OMP& default(shared) ! { dg-warning "starts a commented line" } +!$OMP end parallel +! +!$OMP parallel +!$OMP+ default(shared) ! { dg-warning "starts a commented line" } +!$OMP end parallel + end diff --git a/gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 b/gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 index 9cd5ebf59c0..d4137cd11ec 100644 --- a/gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 @@ -17,7 +17,7 @@ call bar ! Non-continuation !$omp must be followed by space, and my reading ! doesn't seem to allow tab there. So such lines should be completely ! ignored. -!$omp strange +!$omp strange ! { dg-warning "starts a commented line" } end ! { dg-final { scan-tree-dump-times "pragma omp parallel" 3 "omplower" } } -- 2.30.2