Message ID | 54A40B80.4090402@net-b.de |
---|---|
State | New |
Headers | show |
Hi Tobias, > It often happens that one wants to debug PURE procedures but as I/O is not > permitted, this can be difficult. F2008's IMPURE ELEMENTAL helps a bit not > completely. > > Fortran 2015 adds another aid – not I/O which is intrinsically impure – but > at least ERROR STOP is now permitted. > > Attached is this belate Christmas present for Damian and the second F2015 > for GCC 5. (The first was "IMPLICIT NONE (external)".) > > Build and regtested on x86-64-gnu-linux. > OK for the trunk? looks (almost) ok to me. Just one thing about your test cases: Shouldn't the dg-error go into error_stop_4.f90 (where you have -std=f2008ts) instead of error_stop_3.f90 (with -std=gnu)? And then: -/* Match a number or character constant after an (ALL) STOP or PAUSE statement. */ +/* Match a number or character constant after an (ERROR) STOP or PAUSE + statement. */ I don't actually understand what the "(ALL)" was supposed to mean here. There is nothing like an ALL STOP statement, right? Or was it just supposed to refer to *all kinds* of STOP statements? In any case it's good that it is corrected. Btw: It's probably not worth to introduce an option like -std=f2015 yet, but since there is an early draft document already, maybe it would make sense to start a wiki page to document which of those F15 draft features are implemented already? Thanks for the patch, Janus
Hi Janus, Janus Weil wrote: > looks (almost) ok to me. Just one thing about your test cases: > Shouldn't the dg-error go into error_stop_4.f90 (where you have > -std=f2008ts) instead of error_stop_3.f90 (with -std=gnu)? Yes, I missed to re-diff it, after realizing that I mis-inserted the dg-error. > And then: > -/* Match a number or character constant after an (ALL) STOP or PAUSE > statement. */ > +/* Match a number or character constant after an (ERROR) STOP or PAUSE > + statement. */ > > I don't actually understand what the "(ALL)" was supposed to mean > here. The draft Fortran 2008 standard had "ALL STOP" to stop all images of a parallel coarray program when an error occurred. They later renamed it to ERROR STOP. In my coarray draft patches, I first had ALL STOP and then – before the merge (for GCC 4.6, 2010-03) – J3/WG5 renamed it to ERROR STOP. Seemingly, I missed that comment when doing the name change. Committed as Rev. 219127. > Btw: It's probably not worth to introduce an option like -std=f2015 > yet, but since there is an early draft document already, maybe it > would make sense to start a wiki page to document which of those F15 > draft features are implemented already? Currently, it's listed at https://gcc.gnu.org/gcc-5/changes.html#fortran and https://gcc.gnu.org/wiki/GFortran/News#gfortran_5_.28current_development_version.29 ; I think we should wait a bit before starting a https://gcc.gnu.org/wiki/Fortran2015Status page. (The "Introduction" of the F2015 standard lists the major new features.) Regarding -std=f2015: I think we should add that option once the GCC 6 development starts. Tobias
gcc/fortran/ 2014-12-31 Tobias Burnus <burnus@net-b.de> * match.c (gfc_match_stopcode): Permit error stop in pure procedures with F2015. gcc/testsuite/ 2014-12-31 Tobias Burnus <burnus@net-b.de> * gfortran.dg/error_stop_3.f90: New. * gfortran.dg/error_stop_4.f90: New. * gfortran.dg/coarray_3.f90: Remove a dg-error. diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index fb68eec..2b4202b 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2557,7 +2557,8 @@ gfc_match_cycle (void) } -/* Match a number or character constant after an (ALL) STOP or PAUSE statement. */ +/* Match a number or character constant after an (ERROR) STOP or PAUSE + statement. */ static match gfc_match_stopcode (gfc_statement st) @@ -2581,9 +2582,18 @@ gfc_match_stopcode (gfc_statement st) if (gfc_pure (NULL)) { - gfc_error ("%s statement not allowed in PURE procedure at %C", - gfc_ascii_statement (st)); - goto cleanup; + if (st == ST_ERROR_STOP) + { + if (!gfc_notify_std (GFC_STD_F2015, "%s statement at %C in PURE " + "procedure", gfc_ascii_statement (st))) + goto cleanup; + } + else + { + gfc_error ("%s statement not allowed in PURE procedure at %C", + gfc_ascii_statement (st)); + goto cleanup; + } } gfc_unset_implicit_pure (NULL); diff --git a/gcc/testsuite/gfortran.dg/coarray_3.f90 b/gcc/testsuite/gfortran.dg/coarray_3.f90 index 63c3bd3..aba4eb1 100644 --- a/gcc/testsuite/gfortran.dg/coarray_3.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_3.f90 @@ -79,7 +79,7 @@ pure subroutine pureSub() critical ! { dg-error "Image control statement CRITICAL" } end critical ! { dg-error "Expecting END SUBROUTINE statement" } sync all ! { dg-error "Image control statement SYNC" } - error stop ! { dg-error "not allowed in PURE procedure" } + error stop end subroutine pureSub diff --git a/gcc/testsuite/gfortran.dg/error_stop_3.f90 b/gcc/testsuite/gfortran.dg/error_stop_3.f90 new file mode 100644 index 0000000..40fe5de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/error_stop_3.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-std=gnu" } +! +! F2015 permits ERROR STOP in PURE procedures +! FIXME: Change to -std=f2015, when available +! +pure subroutine foo() + error stop "failed" ! { dg-error "GNU Extension: ERROR STOP statement at .1. in PURE procedure" } +end diff --git a/gcc/testsuite/gfortran.dg/error_stop_4.f90 b/gcc/testsuite/gfortran.dg/error_stop_4.f90 new file mode 100644 index 0000000..703a2f2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/error_stop_4.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-std=f2008ts" } +! +! F2015 permits ERROR STOP in PURE procedures +! FIXME: Change to error_stop_3.f90 to -std=f2015. +! +pure subroutine foo() + error stop "failed" +end