From 7031baf4de70d1f280df2c3837861ca042ae79b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Mon, 14 Jun 2004 20:50:44 +0200 Subject: [PATCH] re PR fortran/15211 (ICE with LEN intrinsic) fortran/ PR fortran/15211 * trans-intrinsic.c (gfc_conv_intrinsic_len): Deal with arrays of strings. testsuite/ PR fortran/15211 * gfortran.fortran-torture/execute/intrinsic_len.f90: Also test LEN of a character array. From-SVN: r83126 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-intrinsic.c | 6 +++++- gcc/testsuite/ChangeLog | 6 ++++++ .../gfortran.fortran-torture/execute/intrinsic_len.f90 | 9 +++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 47b7e24df84..04e529005f1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2004-05-31 Tobias Schlueter + + PR fortran/15211 + * trans-intrinsic.c (gfc_conv_intrinsic_len): Deal with arrays + of strings. + 2004-06-14 Tobias Schlueter PR fortran/15510 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index e2c1b7e1529..67b6cc46dad 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -1874,8 +1874,12 @@ gfc_conv_intrinsic_len (gfc_se * se, gfc_expr * expr) break; default: - if (arg->expr_type == EXPR_VARIABLE && arg->ref == NULL) + if (arg->expr_type == EXPR_VARIABLE && arg->ref == NULL + || (arg->ref->next == NULL && arg->ref->type == REF_ARRAY)) { + /* This doesn't catch all cases. + See http://gcc.gnu.org/ml/fortran/2004-06/msg00165.html + and the surrounding thread. */ sym = arg->symtree->n.sym; decl = gfc_get_symbol_decl (sym); if (decl == current_function_decl && sym->attr.function diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0bff3abb8de..36cb478b01c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-06-14 Tobias Schlueter + + PR fortran/15211 + * gfortran.fortran-torture/execute/intrinsic_len.f90: Also test + LEN of a character array. + 2004-06-14 Mark Mitchell PR c++/15096 diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_len.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_len.f90 index 6721738608f..9db8d407a94 100644 --- a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_len.f90 +++ b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_len.f90 @@ -12,6 +12,7 @@ program test if ((a .ne. "01234567") .or. (n .ne. 8)) call abort if (len(Tom%name) .ne. 10) call abort + call array_test() end function w(i) @@ -20,3 +21,11 @@ function w(i) w = "01234567" i = len(w) end + +! This is the testcase from PR 15211 converted to a subroutine +subroutine array_test + implicit none + character(len=10) a(4) + if (len(a) .NE. 10) call abort() +end subroutine array_test + -- 2.30.2