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

Harald Anlauf <anlauf at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gmx dot de

--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
There is a variant that is wrongly rejected:

module m
  implicit none
contains
  function f(n) result(z)
    character, save      :: c(3) = ['x', 'y', 'z']
    integer,  intent(in) :: n
    character(len_trim(c(n))) :: z
    z = c(n)
  end
end
program p
  use m
  print *, f(2)
end

pr84868b.f90:7:23:

     character(len_trim(c(n))) :: z
                       1
Error: Variable 'c' cannot appear in the expression at (1)

With the following patch len_trim is accepted in a specification expression:

Index: expr.c
===================================================================
--- expr.c      (revision 269880)
+++ expr.c      (working copy)
@@ -3402,10 +3402,13 @@
       return false;
     }

-  if (!gfc_simplify_expr (e, 0))
-    return false;
+  if (gfc_simplify_expr (e, 0))
+    return true;

-  return check_restricted (e);
+  if (check_restricted (e))
+    return true;
+
+  return false;
 }

But then we hit the following issue at link time:

pr84868b.f90:(.text+0x12c): undefined reference to `___MOD_c'

Reply via email to