* [PATCH] PR fortran/90290 -- Check F2008 STOP code
@ 2019-05-02 6:02 Steve Kargl
2019-05-02 6:19 ` Janne Blomqvist
0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2019-05-02 6:02 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 443 bytes --]
The attach patch adds an additional check for the
STOP code when -std=f2008 is used. The patch has
been bootstrapped and regression tested on
x86_64-*-freebsd for trunk. OK to commit?
2019-05-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90290
* match.c (gfc_match_stopcode): Check F2008 condition on stop code.
2019-05-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90290
* gfortran.dg/pr90290.f90: New test.
--
Steve
[-- Attachment #2: pr90290.diff --]
[-- Type: text/x-diff, Size: 2137 bytes --]
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 270774)
+++ gcc/fortran/match.c (working copy)
@@ -2955,7 +2955,7 @@ gfc_match_stopcode (gfc_statement st)
{
gfc_expr *e = NULL;
match m;
- bool f95, f03;
+ bool f95, f03, f08;
/* Set f95 for -std=f95. */
f95 = (gfc_option.allow_std == GFC_STD_OPT_F95);
@@ -2963,6 +2963,9 @@ gfc_match_stopcode (gfc_statement st)
/* Set f03 for -std=f2003. */
f03 = (gfc_option.allow_std == GFC_STD_OPT_F03);
+ /* Set f08 for -std=f2008. */
+ f08 = (gfc_option.allow_std == GFC_STD_OPT_F08);
+
/* Look for a blank between STOP and the stop-code for F2008 or later. */
if (gfc_current_form != FORM_FIXED && !(f95 || f03))
{
@@ -3051,8 +3054,8 @@ gfc_match_stopcode (gfc_statement st)
/* Test for F95 and F2003 style STOP stop-code. */
if (e->expr_type != EXPR_CONSTANT && (f95 || f03))
{
- gfc_error ("STOP code at %L must be a scalar CHARACTER constant or "
- "digit[digit[digit[digit[digit]]]]", &e->where);
+ gfc_error ("STOP code at %L must be a scalar CHARACTER constant "
+ "or digit[digit[digit[digit[digit]]]]", &e->where);
goto cleanup;
}
@@ -3061,6 +3064,14 @@ gfc_match_stopcode (gfc_statement st)
gfc_init_expr_flag = true;
gfc_reduce_init_expr (e);
gfc_init_expr_flag = false;
+
+ /* Test for F2008 style STOP stop-code. */
+ if (e->expr_type != EXPR_CONSTANT && f08)
+ {
+ gfc_error ("STOP code at %L must be a scalar default CHARACTER or "
+ "INTEGER constant expression", &e->where);
+ goto cleanup;
+ }
if (!(e->ts.type == BT_CHARACTER || e->ts.type == BT_INTEGER))
{
Index: gcc/testsuite/gfortran.dg/pr90290.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr90290.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr90290.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! { dg-options "-std=f2008" }
+program errorstop
+ integer :: ec
+ read *, ec
+ stop ec ! { dg-error "STOP code at " }
+end program
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/90290 -- Check F2008 STOP code
2019-05-02 6:02 [PATCH] PR fortran/90290 -- Check F2008 STOP code Steve Kargl
@ 2019-05-02 6:19 ` Janne Blomqvist
2019-05-06 23:25 ` Steve Kargl
0 siblings, 1 reply; 3+ messages in thread
From: Janne Blomqvist @ 2019-05-02 6:19 UTC (permalink / raw)
To: Steve Kargl; +Cc: Fortran List, GCC Patches
On Thu, May 2, 2019 at 9:02 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> The attach patch adds an additional check for the
> STOP code when -std=f2008 is used. The patch has
> been bootstrapped and regression tested on
> x86_64-*-freebsd for trunk. OK to commit?
Ok.
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/90290 -- Check F2008 STOP code
2019-05-02 6:19 ` Janne Blomqvist
@ 2019-05-06 23:25 ` Steve Kargl
0 siblings, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2019-05-06 23:25 UTC (permalink / raw)
To: Janne Blomqvist; +Cc: Fortran List, GCC Patches
On Thu, May 02, 2019 at 09:19:10AM +0300, Janne Blomqvist wrote:
> On Thu, May 2, 2019 at 9:02 AM Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> >
> > The attach patch adds an additional check for the
> > STOP code when -std=f2008 is used. The patch has
> > been bootstrapped and regression tested on
> > x86_64-*-freebsd for trunk. OK to commit?
>
> Ok.
>
Committed revision 270928.
I have not decided if I will backport this
to other branches, yet.
--
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-06 23:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 6:02 [PATCH] PR fortran/90290 -- Check F2008 STOP code Steve Kargl
2019-05-02 6:19 ` Janne Blomqvist
2019-05-06 23:25 ` Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).