public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-10596] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036]
Date: Fri, 24 Mar 2023 18:41:55 +0000 (GMT)	[thread overview]
Message-ID: <20230324184155.AB5A7384841D@sourceware.org> (raw)

https://gcc.gnu.org/g:2055702e8d492be6e978fa93a7bfefd358d5d9e3

commit r11-10596-g2055702e8d492be6e978fa93a7bfefd358d5d9e3
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.c (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.c                    | 7 ++++---
 gcc/testsuite/gfortran.dg/pr99036.f90 | 9 +++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 6eb39d36196..efe3a2285a7 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -9902,9 +9902,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

                 reply	other threads:[~2023-03-24 18:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230324184155.AB5A7384841D@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).