void
redeclare(Sym *s, char *where)
{
- yyerror("%S redeclared %s\n"
- "\tprevious declaration at %L",
- s, where, s->lastlineno);
+ if(s->lastlineno == 0)
+ yyerror("%S redeclared %s\n"
+ "\tprevious declaration during import",
+ s, where);
+ else
+ yyerror("%S redeclared %s\n"
+ "\tprevious declaration at %L",
+ s, where, s->lastlineno);
}
/*
if(s->def->op == OPACK) {
// throw away top-level package name leftover
// from previous file.
- // TODO(rsc): remember that there was a package
- // name, so that the name cannot be redeclared
- // as a non-package in other files.
+ // leave s->block set to cause redeclaration
+ // errors if a conflicting top-level name is
+ // introduced by a different file.
if(!s->def->used && !nsyntaxerrors)
yyerrorl(s->def->lineno, "imported and not used: %s", s->def->sym->name);
s->def = N;