public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9311] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036]
@ 2023-03-22 18:00 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-03-22 18:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7eb94c5adfd85c38e4ed7a7fff74b59087ddb813

commit r12-9311-g7eb94c5adfd85c38e4ed7a7fff74b59087ddb813
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Mar 21 19:58:31 2023 +0100

    Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/99036
            * decl.cc (gfc_match_modproc): Reject MODULE PROCEDURE if not in a
            generic module interface.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/99036
            * gfortran.dg/pr99036.f90: New test.
    
    (cherry picked from commit dd282b16bfd3c6e218dffb7798a375365b10ae22)

Diff:
---
 gcc/fortran/decl.cc                   | 7 ++++---
 gcc/testsuite/gfortran.dg/pr99036.f90 | 9 +++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index b6400514731..b89ed17be50 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -9984,9 +9984,10 @@ gfc_match_modproc (void)
   gfc_namespace *module_ns;
   gfc_interface *old_interface_head, *interface;
 
-  if ((gfc_state_stack->state != COMP_INTERFACE
-       && gfc_state_stack->state != COMP_CONTAINS)
-      || gfc_state_stack->previous == NULL
+  if (gfc_state_stack->previous == NULL
+      || (gfc_state_stack->state != COMP_INTERFACE
+	  && (gfc_state_stack->state != COMP_CONTAINS
+	      || gfc_state_stack->previous->state != COMP_INTERFACE))
       || current_interface.type == INTERFACE_NAMELESS
       || current_interface.type == INTERFACE_ABSTRACT)
     {
diff --git a/gcc/testsuite/gfortran.dg/pr99036.f90 b/gcc/testsuite/gfortran.dg/pr99036.f90
new file mode 100644
index 00000000000..a6e396f6f71
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr99036.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/99036 - ICE in gfc_current_interface_head
+! Contributed by G. Steinmetz
+
+module m
+contains
+  module procedure s ! { dg-error "must be in a generic module interface" }
+  end
+end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-22 18:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 18:00 [gcc r12-9311] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036] Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).