https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99036

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-02-10
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from kargl at gcc dot gnu.org ---
Possible patch.  Tested against Gerhard's example.  Not regression tested.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 723915822f3..8cdfdf8f03a 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -9881,6 +9879,12 @@ gfc_match_modproc (void)
   /* Store the current state of the interface. We will need it if we
      end up with a syntax error and need to recover.  */
   old_interface_head = gfc_current_interface_head ();
+  if (!old_interface_head)
+    {
+      gfc_error ("MODULE PROCEDURE at %C must be in a generic module "
+                "interface");
+      return MATCH_ERROR;
+    }

   /* Check if the F2008 optional double colon appears.  */
   gfc_gobble_whitespace ();
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 87fe14280e6..aec5536d7c6 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -4696,7 +4696,7 @@ gfc_current_interface_head (void)
        return current_interface.uop->op;

       default:
-       gcc_unreachable ();
+       return NULL;
     }
 }

Reply via email to