mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +00:00
warn about double function declarations...
This commit is contained in:
parent
5897f0439c
commit
39b8b6a660
2 changed files with 16 additions and 6 deletions
1
opts.def
1
opts.def
|
@ -58,6 +58,7 @@
|
|||
GMQCC_DEFINE_FLAG(ASSIGN_FUNCTION_TYPES)
|
||||
GMQCC_DEFINE_FLAG(PREPROCESSOR)
|
||||
GMQCC_DEFINE_FLAG(MULTIFILE_IF)
|
||||
GMQCC_DEFINE_FLAG(DOUBLE_DECLARATION)
|
||||
#endif
|
||||
|
||||
/* some cleanup so we don't have to */
|
||||
|
|
21
parser.c
21
parser.c
|
@ -3587,14 +3587,23 @@ skipvar:
|
|||
break;
|
||||
}
|
||||
|
||||
func = ast_function_new(ast_ctx(var), var->name, var);
|
||||
if (!func) {
|
||||
parseerror(parser, "failed to allocate function for `%s`", var->name);
|
||||
break;
|
||||
if (var->isconst) {
|
||||
(void)!parsewarning(parser, WARN_DOUBLE_DECLARATION,
|
||||
"builtin `%s` has already been defined\n"
|
||||
" -> previous declaration here: %s:%i",
|
||||
var->name, ast_ctx(var).file, (int)ast_ctx(var).line);
|
||||
}
|
||||
vec_push(parser->functions, func);
|
||||
else
|
||||
{
|
||||
func = ast_function_new(ast_ctx(var), var->name, var);
|
||||
if (!func) {
|
||||
parseerror(parser, "failed to allocate function for `%s`", var->name);
|
||||
break;
|
||||
}
|
||||
vec_push(parser->functions, func);
|
||||
|
||||
func->builtin = -parser_token(parser)->constval.i;
|
||||
func->builtin = -parser_token(parser)->constval.i;
|
||||
}
|
||||
|
||||
if (!parser_next(parser)) {
|
||||
parseerror(parser, "expected comma or semicolon");
|
||||
|
|
Loading…
Reference in a new issue