mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
warn when local variables are redecalred in the same scope. This won't normally cause problems, but it can save a lot of grief when converting traditional quakec code.
This commit is contained in:
parent
8c31f12d5c
commit
cfeb14fecf
1 changed files with 19 additions and 4 deletions
|
@ -549,12 +549,27 @@ code_func
|
||||||
def_name
|
def_name
|
||||||
: identifier
|
: identifier
|
||||||
{
|
{
|
||||||
if (current_scope->type == sc_local
|
scope_type st = current_scope->type;
|
||||||
&& current_scope->parent->type == sc_params) {
|
// traditional functions have only the one scope
|
||||||
|
//FIXME should the scope be set to local when the params scope
|
||||||
|
//is created in traditional mode?
|
||||||
|
if (options.traditional && st == sc_params)
|
||||||
|
st = sc_local;
|
||||||
|
if (st == sc_local) {
|
||||||
def_t *def = get_def (0, $1, current_scope, st_none);
|
def_t *def = get_def (0, $1, current_scope, st_none);
|
||||||
if (def) {
|
if (def) {
|
||||||
if (def->scope->type == sc_params)
|
if (def->scope->type == sc_params
|
||||||
warning (0, "local %s shadows param %s", $1, def->name);
|
&& current_scope->parent->type == sc_params) {
|
||||||
|
warning (0, "local %s shadows param %s", $1,
|
||||||
|
def->name);
|
||||||
|
}
|
||||||
|
if (def->scope == current_scope) {
|
||||||
|
expr_t e;
|
||||||
|
warning (0, "local %s redeclared", $1);
|
||||||
|
e.file = def->file;
|
||||||
|
e.line = def->line;
|
||||||
|
warning (&e, "previously declared here");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$$ = get_def ($<type>0, $1, current_scope, current_storage);
|
$$ = get_def ($<type>0, $1, current_scope, current_storage);
|
||||||
|
|
Loading…
Reference in a new issue