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 r12-3533] Fortran - fix ICE during error recovery checking entry characteristics
Date: Tue, 14 Sep 2021 18:23:57 +0000 (GMT)	[thread overview]
Message-ID: <20210914182357.F19233858402@sourceware.org> (raw)

https://gcc.gnu.org/g:b305ec979d9dfc8153859a62a8ab9dd43c3bfc73

commit r12-3533-gb305ec979d9dfc8153859a62a8ab9dd43c3bfc73
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 14 20:23:27 2021 +0200

    Fortran - fix ICE during error recovery checking entry characteristics
    
    gcc/fortran/ChangeLog:
    
            PR fortran/102311
            * resolve.c (resolve_entries): Attempt to recover cleanly after
            rejecting mismatched function entries.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/102311
            * gfortran.dg/entry_25.f90: New test.

Diff:
---
 gcc/fortran/resolve.c                  |  4 +++-
 gcc/testsuite/gfortran.dg/entry_25.f90 | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 8e5ed1c032c..30b96b2f597 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -811,7 +811,7 @@ resolve_entries (gfc_namespace *ns)
 	      gfc_error ("Function %s at %L has entry %s with mismatched "
 			 "characteristics", ns->entries->sym->name,
 			 &ns->entries->sym->declared_at, el->sym->name);
-	      return;
+	      goto cleanup;
 	    }
 	  else if (ts->type == BT_CHARACTER && ts->u.cl && fts->u.cl
 		   && (((ts->u.cl->length && !fts->u.cl->length)
@@ -917,6 +917,8 @@ resolve_entries (gfc_namespace *ns)
 	    }
 	}
     }
+
+cleanup:
   proc->attr.access = ACCESS_PRIVATE;
   proc->attr.entry_master = 1;
 
diff --git a/gcc/testsuite/gfortran.dg/entry_25.f90 b/gcc/testsuite/gfortran.dg/entry_25.f90
new file mode 100644
index 00000000000..518560aa198
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/entry_25.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR fortran/102311 - ICE during error recovery checking entry characteristics
+
+module m
+contains
+  function f() ! { dg-error "mismatched characteristics" }
+    character(:), allocatable :: f
+    character(1)              :: g
+    f = 'f'
+  entry g()
+    g = 'g'
+  end
+end


                 reply	other threads:[~2021-09-14 18:23 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=20210914182357.F19233858402@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).