Commit c21ffa3e by Steven G. Kargl

re PR fortran/90290 (-std=f2008 should reject non-constant stop and error stop codes)

2019-05-06  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/90290
	* match.c (gfc_match_stopcode): Check F2008 condition on stop code.

2019-05-06  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/90290
	* gfortran.dg/pr90290.f90: New test.

From-SVN: r270928
parent b56be669
2019-05-06 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90290
* match.c (gfc_match_stopcode): Check F2008 condition on stop code.
2019-05-01 Andrew Benson <abensonca@gmail.com> 2019-05-01 Andrew Benson <abensonca@gmail.com>
* module.c (write_module): Initialize module_column before writing * module.c (write_module): Initialize module_column before writing
......
...@@ -2977,7 +2977,7 @@ gfc_match_stopcode (gfc_statement st) ...@@ -2977,7 +2977,7 @@ gfc_match_stopcode (gfc_statement st)
{ {
gfc_expr *e = NULL; gfc_expr *e = NULL;
match m; match m;
bool f95, f03; bool f95, f03, f08;
/* Set f95 for -std=f95. */ /* Set f95 for -std=f95. */
f95 = (gfc_option.allow_std == GFC_STD_OPT_F95); f95 = (gfc_option.allow_std == GFC_STD_OPT_F95);
...@@ -2985,6 +2985,9 @@ gfc_match_stopcode (gfc_statement st) ...@@ -2985,6 +2985,9 @@ gfc_match_stopcode (gfc_statement st)
/* Set f03 for -std=f2003. */ /* Set f03 for -std=f2003. */
f03 = (gfc_option.allow_std == GFC_STD_OPT_F03); 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. */ /* Look for a blank between STOP and the stop-code for F2008 or later. */
if (gfc_current_form != FORM_FIXED && !(f95 || f03)) if (gfc_current_form != FORM_FIXED && !(f95 || f03))
{ {
...@@ -3073,8 +3076,8 @@ gfc_match_stopcode (gfc_statement st) ...@@ -3073,8 +3076,8 @@ gfc_match_stopcode (gfc_statement st)
/* Test for F95 and F2003 style STOP stop-code. */ /* Test for F95 and F2003 style STOP stop-code. */
if (e->expr_type != EXPR_CONSTANT && (f95 || f03)) if (e->expr_type != EXPR_CONSTANT && (f95 || f03))
{ {
gfc_error ("STOP code at %L must be a scalar CHARACTER constant or " gfc_error ("STOP code at %L must be a scalar CHARACTER constant "
"digit[digit[digit[digit[digit]]]]", &e->where); "or digit[digit[digit[digit[digit]]]]", &e->where);
goto cleanup; goto cleanup;
} }
...@@ -3084,6 +3087,14 @@ gfc_match_stopcode (gfc_statement st) ...@@ -3084,6 +3087,14 @@ gfc_match_stopcode (gfc_statement st)
gfc_reduce_init_expr (e); gfc_reduce_init_expr (e);
gfc_init_expr_flag = false; 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)) if (!(e->ts.type == BT_CHARACTER || e->ts.type == BT_INTEGER))
{ {
gfc_error ("STOP code at %L must be either INTEGER or CHARACTER type", gfc_error ("STOP code at %L must be either INTEGER or CHARACTER type",
......
2019-05-06 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90290
* gfortran.dg/pr90290.f90: New test.
2019-05-06 Jakub Jelinek <jakub@redhat.com> 2019-05-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/88709 PR tree-optimization/88709
......
! { dg-do compile }
! { dg-options "-std=f2008" }
program errorstop
integer :: ec
read *, ec
stop ec ! { dg-error "STOP code at " }
end program
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment