re PR fortran/20323 (optional arguments incorrectly accepted in specification expressions)

fortran/
PR fortran/20323
* resolve.c (gfc_resolve): Check if character lengths are
specification expressions.

testsuite/
PR fortran/20323
* gfortran.dg/spec_expr_1.f90: New test.

From-SVN: r96382
This commit is contained in:
Tobias Schlüter 2005-03-13 19:37:17 +01:00 committed by Tobias Schlüter
parent 08cee789cd
commit 8f9c06ca82
4 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2005-03-13 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/20323
* resolve.c (gfc_resolve): Check if character lengths are
specification expressions.
2005-03-12 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/20361

View File

@ -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);

View File

@ -1,3 +1,8 @@
2005-03-13 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/20323
* gfortran.dg/spec_expr_1.f90: New test.
2005-03-13 Joseph S. Myers <joseph@codesourcery.com>
PR c/20402

View File

@ -0,0 +1,12 @@
! { 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