* io.c (check_format_string): Only check character expressions.
(match_dt_format): Return MATCH_ERROR if that is what
gfc_match_st_label said.
* gfortran.dg/fmt_label_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130249
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-11-17 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/34108
+ * io.c (check_format_string): Only check character expressions.
+ (match_dt_format): Return MATCH_ERROR if that is what
+ gfc_match_st_label said.
+
2007-11-16 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/33957
static try
check_format_string (gfc_expr *e, bool is_input)
{
- if (!e || e->expr_type != EXPR_CONSTANT)
+ if (!e || e->ts.type != BT_CHARACTER || e->expr_type != EXPR_CONSTANT)
return SUCCESS;
mode = MODE_STRING;
locus where;
gfc_expr *e;
gfc_st_label *label;
+ match m;
where = gfc_current_locus;
return MATCH_YES;
}
- if (gfc_match_st_label (&label) == MATCH_YES)
+ if ((m = gfc_match_st_label (&label)) == MATCH_YES)
{
if (dt->format_expr != NULL || dt->format_label != NULL)
{
dt->format_label = label;
return MATCH_YES;
}
+ else if (m == MATCH_ERROR)
+ /* The label was zero or too large. Emit the correct diagnosis. */
+ return MATCH_ERROR;
if (gfc_match_expr (&e) == MATCH_YES)
{
+2007-11-17 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/34108
+ * gfortran.dg/fmt_label_1.f90: New test.
+
2007-11-16 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/33957
--- /dev/null
+! { dg-do compile }
+!
+! Check for diagnostics (PR 34108)
+ write (*,0) 'xxx' ! { dg-error "Statement label .* is zero" }
+ write (*,1) 'xxx' ! { dg-error "FORMAT label .* not defined" }
+ write (*,123456) 'xxx' ! { dg-error "Too many digits in statement label" }
+ write (*,-1) 'xxx' ! { dg-error "" }
+ end