public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, committed] Fortran: do not generate conflicting results under -ff2c [PR104313]
Date: Fri, 15 Jul 2022 22:18:12 +0200	[thread overview]
Message-ID: <trinity-14a5c972-606f-4e80-bbb5-d18516cc5f36-1657916292209@3c-app-gmx-bap24> (raw)

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

Dear all,

the attached patch by Steve fixes a regression under -ff2c for functions
where the result is not set.  There would otherwise be conflicting
declarations of the returned result, which gimple doesn't like.

I've committed this as obvious after discussion with Steve for him,
see PR, as

commit r13-1715-g517fb1a78102df43f052c6934c27dd51d786aff7

This fixes a 10/11/12/13 regression, will be backported in the next days.

Thanks,
Harald


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr104313.diff --]
[-- Type: text/x-patch, Size: 1889 bytes --]

From 517fb1a78102df43f052c6934c27dd51d786aff7 Mon Sep 17 00:00:00 2001
From: Steve Kargl <kargl@gcc.gnu.org>
Date: Fri, 15 Jul 2022 22:07:15 +0200
Subject: [PATCH] Fortran: do not generate conflicting results under -ff2c
 [PR104313]

gcc/fortran/ChangeLog:

	PR fortran/104313
	* trans-decl.cc (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.
---
 gcc/fortran/trans-decl.cc            |  2 +-
 gcc/testsuite/gfortran.dg/pr104313.f | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr104313.f

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 6493cc2f6b1..908a4c6d42e 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -6474,7 +6474,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" } }
--
2.35.3


                 reply	other threads:[~2022-07-15 20:18 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=trinity-14a5c972-606f-4e80-bbb5-d18516cc5f36-1657916292209@3c-app-gmx-bap24 \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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).