From: Steven G. Kargl Date: Mon, 18 May 2015 22:52:52 +0000 (+0000) Subject: re PR fortran/66052 (Segmentation fault for misplaced protected statement) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=73641c881f4bfb156aca31fe78976a7236722e38;p=gcc.git re PR fortran/66052 (Segmentation fault for misplaced protected statement) 2015-05-18 Steven G. Kargl PR fortran/66052 * decl.c(gfc_match_protected): Prevent dereference of NULL pointer. 2015-05-18 Steven G. Kargl PR fortran/66052 * gfortran.dg/protected_9.f90: New test. From-SVN: r223324 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a8598a2004a..f54de3c335b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -3,6 +3,11 @@ PR fortran/66043 * gfortran.dg/storage_size_6.f90: New tests. +2015-05-18 Steven G. Kargl + + PR fortran/66043 + * gfortran.dg/storage_size_6.f90: New tests. + 2015-05-18 Steven G. Kargl PR fortran/66044 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f8d471aa3de..93a4554343f 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6968,7 +6968,8 @@ gfc_match_protected (void) gfc_symbol *sym; match m; - if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE) + if (!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 1ae1f08f49c..fa8dc0a2086 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-18 Steven G. Kargl + + PR fortran/66043 + * gfortran.dg/storage_size_6.f90: New tests. + 2015-05-18 Steven G. Kargl PR fortran/66045 diff --git a/gcc/testsuite/gfortran.dg/protected_9.f90 b/gcc/testsuite/gfortran.dg/protected_9.f90 new file mode 100644 index 00000000000..2786419f53a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/protected_9.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/66052 +! +! +! Original code from Gerhard Steinmetz +! +module a + contains + protected x ! { dg-error "only allowed in specification part" } +end module a + +program p + contains + protected x ! { dg-error "only allowed in specification part" } +end