re PR fortran/66052 (Segmentation fault for misplaced protected statement)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 18 May 2015 22:52:52 +0000 (22:52 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 18 May 2015 22:52:52 +0000 (22:52 +0000)
2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/66052
* decl.c(gfc_match_protected): Prevent dereference of NULL pointer.

2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/66052
* gfortran.dg/protected_9.f90: New test.

From-SVN: r223324

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/protected_9.f90 [new file with mode: 0644]

index a8598a2004a7f7e5f8caa447cb71394f16397c57..f54de3c335b591eb5ac49c24e34896751e279d2a 100644 (file)
@@ -3,6 +3,11 @@
        PR fortran/66043
        * gfortran.dg/storage_size_6.f90: New tests.
 
+2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66043
+       * gfortran.dg/storage_size_6.f90: New tests.
+
 2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/66044
index f8d471aa3de5426e7d7d79f854a29ae947df2d82..93a4554343fe34ced41f6030cc5e04c39959c1e6 100644 (file)
@@ -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");
index 1ae1f08f49c6bd2eeea57fa4bebdb99d54809080..fa8dc0a2086c658a3c44ee6391a951f108b5ad06 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66043
+       * gfortran.dg/storage_size_6.f90: New tests.
+
 2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        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 (file)
index 0000000..2786419
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/66052
+!
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+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