This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix PR 20323: Correctly resolve character lenghts
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 13 Mar 2005 14:05:06 +0100
- Subject: [gfortran] Fix PR 20323: Correctly resolve character lenghts
We didn't check if character length expressions were indeed specification
expressions. Fixed thusly.
Bubblestrapped and regtested. Patch and new testcase attached. Ok?
- Tobi
2005-03-13 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/20323
* resolve.c (gfc_resolve): Check if character lengths are
specification expressions.
Index: resolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.35
diff -u -p -r1.35 resolve.c
--- resolve.c 5 Mar 2005 22:13:21 -0000 1.35
+++ resolve.c 13 Mar 2005 13:01:27 -0000
@@ -4749,10 +4749,11 @@ gfc_resolve (gfc_namespace * ns)
if (cl->length == NULL || gfc_resolve_expr (cl->length) == FAILURE)
continue;
- if (cl->length->ts.type != BT_INTEGER)
- gfc_error
- ("Character length specification at %L must be of type INTEGER",
- &cl->length->where);
+ if (gfc_simplify_expr (cl->length, 0) == FAILURE)
+ continue;
+
+ if (gfc_specification_expr (cl->length) == FAILURE)
+ continue;
}
gfc_traverse_ns (ns, resolve_values);
! { dg-do compile }
! PR 20323
! We didn't verify that character length expressions are specification
! expressions.
function testpresent(arg)
integer, intent(in), optional :: arg
character(len=arg) :: s ! { dg-error "OPTIONAL" }
logical :: testpresent
testpresent=.true.
end function testpresent