public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10898] Fortran: do not generate conflicting results under -ff2c [PR104313]
@ 2022-07-16 18:48 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-07-16 18:48 UTC (permalink / raw)
  To: gcc-cvs

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" } }


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

only message in thread, other threads:[~2022-07-16 18:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 18:48 [gcc r10-10898] Fortran: do not generate conflicting results under -ff2c [PR104313] 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).