https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115039

            Bug ID: 115039
           Summary: Statement function with inquiry refs rejected
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

As reported in:

https://fortran-lang.discourse.group/t/real-and-imaginary-parts-of-complex-number/1113/18

an inquiry reference (%re, %im) is incorrectly reported as a recursive
reference.

Testcase:

program testit
implicit none
complex :: x
real    :: img
img(x) = x%im
   write (*, *) img((1.0,3.0) + (2.0,4.0))
end program testit


Tentative fix:

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 66edad58278..94ec2ce21dd 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -5500,7 +5546,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 ();

Reply via email to