+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>
* intrinsic.texi (CMPLX): Document result kind.
syntax:
gfc_error ("Syntax error in CHARACTER declaration at %C");
m = MATCH_ERROR;
+ gfc_free_expr (len);
+ return m;
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);
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)
{
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>
PR 31775
--- /dev/null
+! { 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