public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran: fix dependency checks for inquiry refs [PR115039]
@ 2024-05-10 19:24 Harald Anlauf
  2024-05-10 20:48 ` Mikael Morin
  0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2024-05-10 19:24 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Dear all,

the attached simple and obvious patch fixes a bogus recursion error
with inquiry refs used statement functions.  The commit message
says all there is to say...

Regtested on x86_64-pc-linux-gnu.

I intend to commit to mainline within the next 24 hours unless someone
screams...  Will also backport to 14-branch after a decent delay.

Thanks,
Harald


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

From 8bb31eb3d7f8ea6d21066380c36abf53f7b64156 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Fri, 10 May 2024 21:18:03 +0200
Subject: [PATCH] Fortran: fix dependency checks for inquiry refs [PR115039]

gcc/fortran/ChangeLog:

	PR fortran/115039
	* expr.cc (gfc_traverse_expr): An inquiry ref does not constitute
	a dependency and cannot collide with a symbol.

gcc/testsuite/ChangeLog:

	PR fortran/115039
	* gfortran.dg/statement_function_5.f90: New test.
---
 gcc/fortran/expr.cc                           |  3 ++-
 .../gfortran.dg/statement_function_5.f90      | 20 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/statement_function_5.f90

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 66edad58278..8e29535b0f7 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -5500,7 +5500,8 @@ gfc_traverse_expr (gfc_expr *expr, gfc_symbol *sym,
 	  break;

 	case REF_INQUIRY:
-	  return true;
+	  /* An inquiry_ref does not collide with a symbol.  */
+	  return false;

 	default:
 	  gcc_unreachable ();
diff --git a/gcc/testsuite/gfortran.dg/statement_function_5.f90 b/gcc/testsuite/gfortran.dg/statement_function_5.f90
new file mode 100644
index 00000000000..bc5a5dba7a0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/statement_function_5.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/115039
+!
+! Check that inquiry refs work with statement functions
+!
+! { dg-additional-options "-std=legacy -fdump-tree-optimized" }
+! { dg-prune-output " Obsolescent feature" }
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "optimized" } }
+
+program testit
+  implicit none
+  complex :: x
+  real    :: im
+  integer :: slen
+  character(5) :: s
+  im(x)   = x%im + x%re + x%kind
+  slen(s) = s%len
+  if (im((1.0,3.0) + (2.0,4.0)) /= 14.) stop 1
+  if (slen('abcdef') /= 5)              stop 2
+end program testit
--
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fortran: fix dependency checks for inquiry refs [PR115039]
  2024-05-10 19:24 [PATCH] Fortran: fix dependency checks for inquiry refs [PR115039] Harald Anlauf
@ 2024-05-10 20:48 ` Mikael Morin
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Morin @ 2024-05-10 20:48 UTC (permalink / raw)
  To: Harald Anlauf, fortran, gcc-patches

Le 10/05/2024 à 21:24, Harald Anlauf a écrit :
> Dear all,
> 
> the attached simple and obvious patch fixes a bogus recursion error
> with inquiry refs used statement functions.  The commit message
> says all there is to say...
> 
> Regtested on x86_64-pc-linux-gnu.
> 
> I intend to commit to mainline within the next 24 hours unless someone
> screams...  Will also backport to 14-branch after a decent delay.
> 
> Thanks,
> Harald
> 
I agree that the return value change makes sense, but the function is 
generic, broader than just dependency checking, so the comment feels a 
bit out of place.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-10 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 19:24 [PATCH] Fortran: fix dependency checks for inquiry refs [PR115039] Harald Anlauf
2024-05-10 20:48 ` Mikael Morin

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).