From 721be0f47c5c0bb994af6df6f2e2793f9bd13ee3 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 29 Oct 2015 17:23:52 +0000 Subject: [PATCH] re PR fortran/68054 (ICE on using protected attribute in program without program statement) 2015-10-29 Steven G. Kargl PR fortran/68054 * decl.c (match_attr_spec): PROTECTED can only be a module. 2015-10-29 Steven G. Kargl PR fortran/68054 * gfortran.dg/pr68054.f90: New test. From-SVN: r229542 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/decl.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr68054.f90 | 8 ++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr68054.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5aed4bdde88..587045d0579 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-10-29 Steven G. Kargl + + PR fortran/68054 + * decl.c (match_attr_spec): PROTECTED can only be a module. + 2015-10-29 Steven G. Kargl PR fortran/67885 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 5c34dc94387..6a7f3864ded 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -3959,7 +3959,9 @@ match_attr_spec (void) break; case DECL_PROTECTED: - if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE) + if (gfc_current_state () != COMP_MODULE + || (gfc_current_ns->proc_name + && gfc_current_ns->proc_name->attr.flavor != FL_MODULE)) { gfc_error ("PROTECTED at %C only allowed in specification " "part of a module"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee3ac60efef..0ec41025170 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-29 Steven G. Kargl + + PR fortran/68054 + * gfortran.dg/pr68054.f90: New test. + 2015-10-29 Steven G. Kargl PR fortran/67885 diff --git a/gcc/testsuite/gfortran.dg/pr68054.f90 b/gcc/testsuite/gfortran.dg/pr68054.f90 new file mode 100644 index 00000000000..c4b6a341f57 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68054.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/68054 +! Original code contributed by Gerhard Steinmetz +! gerhard dot steinmetz dot fortran at t-online dot de +! +!program p + real, protected :: x ! { dg-error "only allowed in specification" } +end -- 2.30.2