From c286c29493938ae70e8833667e48cf228c193990 Mon Sep 17 00:00:00 2001 From: kargl Date: Fri, 13 Nov 2015 21:11:42 +0000 Subject: [PATCH] 2015-11-13 Steven G. Kargl PR fortran/68319 * decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206. * io.c (gfc_match_format): Ditto. * match.c (gfc_match_st_function): Ditto. 2015-11-13 Steven G. Kargl PR fortran/68319 * gfortran.dg/pr68319.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230351 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/decl.c | 16 ++++++++++++++++ gcc/fortran/io.c | 9 +++++++++ gcc/fortran/match.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr68319.f90 | 26 ++++++++++++++++++++++++++ 6 files changed, 72 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr68319.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b2c1d9b..a455b6b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-11-13 Steven G. Kargl + + PR fortran/68319 + * decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206. + * io.c (gfc_match_format): Ditto. + * match.c (gfc_match_st_function): Ditto. + 2015-11-13 David Malcolm * error.c (gfc_warning): Pass line_table to rich_location ctor. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index c10557e..6d76a7f 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -552,6 +552,15 @@ gfc_match_data (void) gfc_data *new_data; match m; + /* Before parsing the rest of a DATA statement, check F2008:c1206. */ + if ((gfc_current_state () == COMP_FUNCTION + || gfc_current_state () == COMP_SUBROUTINE) + && gfc_state_stack->previous->state == COMP_INTERFACE) + { + gfc_error ("DATA statement at %C cannot appear within an INTERFACE"); + return MATCH_ERROR; + } + set_in_match_data (true); for (;;) @@ -5767,6 +5776,13 @@ gfc_match_entry (void) return MATCH_ERROR; } + if ((state == COMP_SUBROUTINE || state == COMP_FUNCTION) + && gfc_state_stack->previous->state == COMP_INTERFACE) + { + gfc_error ("ENTRY statement at %C cannot appear within an INTERFACE"); + return MATCH_ERROR; + } + module_procedure = gfc_current_ns->parent != NULL && gfc_current_ns->parent->proc_name && gfc_current_ns->parent->proc_name->attr.flavor diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index dbd02b3..8cf952f 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1199,6 +1199,15 @@ gfc_match_format (void) return MATCH_ERROR; } + /* Before parsing the rest of a FORMAT statement, check F2008:c1206. */ + if ((gfc_current_state () == COMP_FUNCTION + || gfc_current_state () == COMP_SUBROUTINE) + && gfc_state_stack->previous->state == COMP_INTERFACE) + { + gfc_error ("FORMAT statement at %C cannot appear within an INTERFACE"); + return MATCH_ERROR; + } + if (gfc_statement_label == NULL) { gfc_error ("Missing format label at %C"); diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d4ba350..22b0d7d 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4913,6 +4913,15 @@ gfc_match_st_function (void) sym->value = expr; + if ((gfc_current_state () == COMP_FUNCTION + || gfc_current_state () == COMP_SUBROUTINE) + && gfc_state_stack->previous->state == COMP_INTERFACE) + { + gfc_error ("Statement function at %L cannot appear within an INTERFACE", + &expr->where); + return MATCH_ERROR; + } + if (!gfc_notify_std (GFC_STD_F95_OBS, "Statement function at %C")) return MATCH_ERROR; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index deb1a71..e01d0c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-13 Steven G. Kargl + + PR fortran/68319 + * gfortran.dg/pr68319.f90: New test. + 2015-11-13 Michael Meissner * gcc.target/powerpc/float128-hw.c: New test for IEEE 128-bit diff --git a/gcc/testsuite/gfortran.dg/pr68319.f90 b/gcc/testsuite/gfortran.dg/pr68319.f90 new file mode 100644 index 0000000..941316d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68319.f90 @@ -0,0 +1,26 @@ +! { dg-do compile } +! PR fortran/68319 +! +subroutine foo + + interface + + real function bar(i) + f(i) = 2 * i ! { dg-error "cannot appear within" } + end function bar + + real function bah(j) + entry boo(j) ! { dg-error "cannot appear within" } + end function bah + + real function fu(j) + data i /1/ ! { dg-error "cannot appear within" } + end function fu + + real function fee(j) +10 format('(A)') ! { dg-error "cannot appear within" } + end function fee + + end interface + +end subroutine foo -- 2.7.4