gfc_st_label *format_label;
gfc_st_label *err, *end, *eor;
- locus eor_where, end_where, err_where;
+ locus eor_where, end_where, err_where, nml_where;
}
gfc_dt;
char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_symbol *sym;
match m;
+ locus where;
if (gfc_match (" unit =") == MATCH_YES)
{
return m;
}
+ where = gfc_current_locus;
if (gfc_match (" nml = %n", name) == MATCH_YES)
{
if (dt->namelist != NULL)
}
dt->namelist = sym;
+ dt->nml_where = where;
if (k == M_READ && check_namelist (sym))
return MATCH_ERROR;
gfc_expr* e;
bool t;
+ e = gfc_get_variable_expr (gfc_find_sym_in_symtree (n->sym));
+
if (k == M_READ)
{
- e = gfc_get_variable_expr (gfc_find_sym_in_symtree (n->sym));
t = gfc_check_vardef_context (e, false, false, false, NULL);
gfc_free_expr (e);
dt->namelist->name, loc, n->sym->name);
return false;
}
- gfc_value_set_at (n->sym, NULL, VALUE_VARDEF);
+ gfc_value_set_at (n->sym, &dt->nml_where, VALUE_READ);
}
+ else if (k == M_WRITE || k == M_PRINT)
+ {
+ e->where = dt->nml_where;
+ gfc_value_used_expr (e, VALUE_USED);
+ gfc_free_expr (e);
+ }
+
+ n->sym->attr.referenced = 1;
t = dtio_procs_present (n->sym, k);
m = MATCH_ERROR;
goto cleanup;
}
+ dt->nml_where = where;
goto next;
}
}
case EXEC_END_BLOCK:
case EXEC_END_NESTED_BLOCK:
case EXEC_CYCLE:
- case EXEC_PAUSE:
break;
case EXEC_STOP:
|| code->expr2->rank != 0))
gfc_error ("QUIET specifier at %L must be a scalar LOGICAL",
&code->expr2->where);
+
+ /* Fall through. */
+ case EXEC_PAUSE:
+ gfc_value_used_expr (code->expr1, VALUE_USED);
break;
case EXEC_EXIT:
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-Wundefined-vars" }
+program memain
+ implicit none
+ integer :: n, m
+ namelist /n1/ n
+ namelist /n2/ m
+ write (*,n1) ! { dg-warning "Undefined variable" }
+ write (*,nml=n2) ! { dg-warning "Undefined variable" }
+end program memain
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-Wundefined-vars -std=legacy" }
+! PR 126090 - warnings with STOP and friends
+program memain
+ character(8) :: s
+ character(8) :: s1, s2, s3
+ s = "abc"
+ error stop s
+ stop s
+ pause s
+ error stop s1 ! { dg-warning "Undefined variable" }
+ stop s2 ! { dg-warning "Undefined variable" }
+ pause s3 ! { dg-warning "Undefined variable" }
+end program memain