mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
Enable 'local-already-declared' check for locals even when they are functions - this was previously simply in the wrong 'if'
This commit is contained in:
parent
8e30d7cb86
commit
e87fd30c48
1 changed files with 46 additions and 46 deletions
92
parser.c
92
parser.c
|
@ -2510,61 +2510,61 @@ static bool parse_variable(parser_t *parser, ast_block *localblock)
|
|||
goto cleanup;
|
||||
}
|
||||
}
|
||||
else /* if it's a local: */
|
||||
}
|
||||
if (localblock) /* if it's a local: */
|
||||
{
|
||||
olddecl = parser_find_local(parser, var->name, parser->blocklocal, &isparam);
|
||||
if (opts_standard == COMPILER_GMQCC)
|
||||
{
|
||||
olddecl = parser_find_local(parser, var->name, parser->blocklocal, &isparam);
|
||||
if (opts_standard == COMPILER_GMQCC)
|
||||
if (olddecl)
|
||||
{
|
||||
if (olddecl)
|
||||
{
|
||||
if (!isparam) {
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if( (!isparam && olddecl) ||
|
||||
(olddecl = parser_find_local(parser, var->name, 0, &isparam))
|
||||
)
|
||||
{
|
||||
if (parsewarning(parser, WARN_LOCAL_SHADOWS,
|
||||
"local `%s` is shadowing a parameter", var->name))
|
||||
{
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
if (!isparam) {
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if( (!isparam && olddecl) ||
|
||||
(olddecl = parser_find_local(parser, var->name, 0, &isparam))
|
||||
)
|
||||
{
|
||||
if (olddecl)
|
||||
if (parsewarning(parser, WARN_LOCAL_SHADOWS,
|
||||
"local `%s` is shadowing a parameter", var->name))
|
||||
{
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (olddecl)
|
||||
{
|
||||
if (isparam &&
|
||||
parsewarning(parser, WARN_LOCAL_SHADOWS,
|
||||
"a parameter is shadowing local `%s`", var->name))
|
||||
{
|
||||
if (isparam &&
|
||||
parsewarning(parser, WARN_LOCAL_SHADOWS,
|
||||
"a parameter is shadowing local `%s`", var->name))
|
||||
{
|
||||
ast_value_delete(var);
|
||||
var = NULL;
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
else if (!isparam)
|
||||
{
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
ast_value_delete(var);
|
||||
var = NULL;
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
ast_value_delete(var);
|
||||
var = NULL;
|
||||
goto nextvar;
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
else if (!isparam)
|
||||
{
|
||||
parseerror(parser, "local `%s` already declared here: %s:%i",
|
||||
var->name, ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
|
||||
ast_value_delete(var);
|
||||
var = NULL;
|
||||
retval = false;
|
||||
goto cleanup;
|
||||
}
|
||||
ast_value_delete(var);
|
||||
var = NULL;
|
||||
goto nextvar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue