to return false upon finding an existing global entry. */
static bool
-add_global_entry (const char *name, const char *binding_label, bool sub)
+add_global_entry (const char *name, const char *binding_label, bool sub,
+ locus *where)
{
gfc_gsymbol *s;
enum gfc_symbol_type type;
if (s->defined || (s->type != GSYM_UNKNOWN && s->type != type))
{
- gfc_global_used(s, NULL);
+ gfc_global_used (s, where);
return false;
}
else
{
s->type = type;
s->sym_name = name;
- s->where = gfc_current_locus;
+ s->where = *where;
s->defined = 1;
s->ns = gfc_current_ns;
}
if (s->defined || (s->type != GSYM_UNKNOWN && s->type != type))
{
- gfc_global_used(s, NULL);
+ gfc_global_used (s, where);
return false;
}
else
s->type = type;
s->sym_name = name;
s->binding_label = binding_label;
- s->where = gfc_current_locus;
+ s->where = *where;
s->defined = 1;
s->ns = gfc_current_ns;
}
/* Check what next non-whitespace character is so we can tell if there
is the required parens if we have a BIND(C). */
+ old_loc = gfc_current_locus;
gfc_gobble_whitespace ();
peek_char = gfc_peek_ascii_char ();
}
if (!gfc_current_ns->parent
- && !add_global_entry (name, entry->binding_label, true))
+ && !add_global_entry (name, entry->binding_label, true,
+ &old_loc))
return MATCH_ERROR;
/* An entry in a subroutine. */
ENTRY f() RESULT (r)
can't be written as
ENTRY f RESULT (r). */
- old_loc = gfc_current_locus;
if (gfc_match_eos () == MATCH_YES)
{
gfc_current_locus = old_loc;
}
if (!gfc_current_ns->parent
- && !add_global_entry (name, entry->binding_label, false))
+ && !add_global_entry (name, entry->binding_label, false,
+ &old_loc))
return MATCH_ERROR;
}
goto cleanup;
}
+ old_loc = gfc_current_locus;
if (gfc_match_eos () == MATCH_YES)
{
if (!eos_ok && (*st == ST_END_SUBROUTINE || *st == ST_END_FUNCTION))
/* Verify that we've got the sort of end-block that we're expecting. */
if (gfc_match (target) != MATCH_YES)
{
- gfc_error ("Expecting %s statement at %C", gfc_ascii_statement (*st));
+ gfc_error ("Expecting %s statement at %L", gfc_ascii_statement (*st),
+ &old_loc);
goto cleanup;
}
+ old_loc = gfc_current_locus;
/* If we're at the end, make sure a block name wasn't required. */
if (gfc_match_eos () == MATCH_YES)
{
if (!block_name)
return MATCH_YES;
- gfc_error ("Expected block name of '%s' in %s statement at %C",
- block_name, gfc_ascii_statement (*st));
+ gfc_error ("Expected block name of '%s' in %s statement at %L",
+ block_name, gfc_ascii_statement (*st), &old_loc);
return MATCH_ERROR;
}
s = gfc_get_gsymbol (gfc_new_block->name);
if (s->defined
|| (s->type != GSYM_UNKNOWN && s->type != GSYM_BLOCK_DATA))
- gfc_global_used(s, NULL);
+ gfc_global_used (s, &gfc_new_block->declared_at);
else
{
s->type = GSYM_BLOCK_DATA;
- s->where = gfc_current_locus;
+ s->where = gfc_new_block->declared_at;
s->defined = 1;
}
}
s = gfc_get_gsymbol (gfc_new_block->name);
if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_MODULE))
- gfc_global_used(s, NULL);
+ gfc_global_used (s, &gfc_new_block->declared_at);
else
{
s->type = GSYM_MODULE;
- s->where = gfc_current_locus;
+ s->where = gfc_new_block->declared_at;
s->defined = 1;
}
|| (s->type != GSYM_UNKNOWN
&& s->type != (sub ? GSYM_SUBROUTINE : GSYM_FUNCTION)))
{
- gfc_global_used (s, NULL);
+ gfc_global_used (s, &gfc_new_block->declared_at);
/* Silence follow-up errors. */
gfc_new_block->binding_label = NULL;
}
{
s->type = sub ? GSYM_SUBROUTINE : GSYM_FUNCTION;
s->sym_name = gfc_new_block->name;
- s->where = gfc_current_locus;
+ s->where = gfc_new_block->declared_at;
s->defined = 1;
s->ns = gfc_current_ns;
}
|| (s->type != GSYM_UNKNOWN
&& s->type != (sub ? GSYM_SUBROUTINE : GSYM_FUNCTION)))
{
- gfc_global_used (s, NULL);
+ gfc_global_used (s, &gfc_new_block->declared_at);
/* Silence follow-up errors. */
gfc_new_block->binding_label = NULL;
}
s->type = sub ? GSYM_SUBROUTINE : GSYM_FUNCTION;
s->sym_name = gfc_new_block->name;
s->binding_label = gfc_new_block->binding_label;
- s->where = gfc_current_locus;
+ s->where = gfc_new_block->declared_at;
s->defined = 1;
s->ns = gfc_current_ns;
}
s = gfc_get_gsymbol (gfc_new_block->name);
if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_PROGRAM))
- gfc_global_used(s, NULL);
+ gfc_global_used (s, &gfc_new_block->declared_at);
else
{
s->type = GSYM_PROGRAM;
- s->where = gfc_current_locus;
+ s->where = gfc_new_block->declared_at;
s->defined = 1;
s->ns = gfc_current_ns;
}