Commit 16f8ffc8 by Jerry DeLisle

re PR fortran/31251 (Non-integer character length leads to segfault)

2007-05-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/31251
	* decl.c (match_char_spec): Add check for invalid character lengths.

2007-05-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/31251
	* gfortran.dg/char_type_len_2.f90: New test.

From-SVN: r124469
parent a758fa89
2007-05-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31251
* decl.c (match_char_spec): Add check for invalid character lengths.
2007-05-04 Brooks Moses <brooks.moses@codesourcery.com> 2007-05-04 Brooks Moses <brooks.moses@codesourcery.com>
* intrinsic.texi (CMPLX): Document result kind. * intrinsic.texi (CMPLX): Document result kind.
......
...@@ -1626,14 +1626,23 @@ rparen: ...@@ -1626,14 +1626,23 @@ rparen:
syntax: syntax:
gfc_error ("Syntax error in CHARACTER declaration at %C"); gfc_error ("Syntax error in CHARACTER declaration at %C");
m = MATCH_ERROR; m = MATCH_ERROR;
gfc_free_expr (len);
return m;
done: done:
if (m == MATCH_YES && gfc_validate_kind (BT_CHARACTER, kind, true) < 0) if (gfc_validate_kind (BT_CHARACTER, kind, true) < 0)
{ {
gfc_error ("Kind %d is not a CHARACTER kind at %C", kind); gfc_error ("Kind %d is not a CHARACTER kind at %C", kind);
m = MATCH_ERROR; m = MATCH_ERROR;
} }
if (seen_length == 1 && len != NULL
&& len->ts.type != BT_INTEGER && len->ts.type != BT_UNKNOWN)
{
gfc_error ("Expression at %C must be of INTEGER type");
m = MATCH_ERROR;
}
if (m != MATCH_YES) if (m != MATCH_YES)
{ {
gfc_free_expr (len); gfc_free_expr (len);
......
2007-05-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31251
* gfortran.dg/char_type_len_2.f90: New test.
2007-05-05 Geoffrey Keating <geoffk@apple.com> 2007-05-05 Geoffrey Keating <geoffk@apple.com>
PR 31775 PR 31775
! { dg-do compile }
! PR31251 Non-integer character length leads to segfault
! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
character(len=2.3) :: s ! { dg-error "must be of INTEGER type" }
character(kind=1,len=4.3) : t ! { dg-error "must be of INTEGER type" }
character(len=,,7.2,kind=1) : u ! { dg-error "Syntax error in CHARACTER declaration" }
character(len=7,kind=2) : v ! ! { dg-error "Kind 2 is not a CHARACTER kind" }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment