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 r10-10898] Fortran: do not generate conflicting results under -ff2c [PR104313]
Date: Sat, 16 Jul 2022 18:48:48 +0000 (GMT)	[thread overview]
Message-ID: <20220716184848.376AA3858D39@sourceware.org> (raw)

https://gcc.gnu.org/g:168a1ae79bb86bdfe482c7c80ea742d40cc414c5

commit r10-10898-g168a1ae79bb86bdfe482c7c80ea742d40cc414c5
Author: Steve Kargl <kargl@gcc.gnu.org>
Date:   Fri Jul 15 22:07:15 2022 +0200

    Fortran: do not generate conflicting results under -ff2c [PR104313]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/104313
            * trans-decl.c (gfc_generate_return): Do not generate conflicting
            fake results for functions with no result variable under -ff2c.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/104313
            * gfortran.dg/pr104313.f: New test.
    
    (cherry picked from commit 517fb1a78102df43f052c6934c27dd51d786aff7)

Diff:
---
 gcc/fortran/trans-decl.c             |  2 +-
 gcc/testsuite/gfortran.dg/pr104313.f | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 8aa71ede989..765c492520c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -6545,7 +6545,7 @@ gfc_generate_return (void)
 	     NULL_TREE, and a 'return' is generated without a variable.
 	     The following generates a 'return __result_XXX' where XXX is
 	     the function name.  */
-	  if (sym == sym->result && sym->attr.function)
+	  if (sym == sym->result && sym->attr.function && !flag_f2c)
 	    {
 	      result = gfc_get_fake_result_decl (sym, 0);
 	      result = fold_build2_loc (input_location, MODIFY_EXPR,
diff --git a/gcc/testsuite/gfortran.dg/pr104313.f b/gcc/testsuite/gfortran.dg/pr104313.f
new file mode 100644
index 00000000000..89c8947cb0a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr104313.f
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-additional-options "-ff2c -fdump-tree-original" }
+!
+! PR fortran/104313 - ICE verify_gimple failed with -ff2c
+! Contributed by G.Steinmetz
+
+      function f(a)
+      return
+      end
+
+! { dg-final { scan-tree-dump-times "return" 1 "original" } }


                 reply	other threads:[~2022-07-16 18:48 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=20220716184848.376AA3858D39@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).