warn about double function declarations...

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-23 22:22:22 +01:00
parent 5897f0439c
commit 39b8b6a660
2 changed files with 16 additions and 6 deletions

View file

@ -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 */

View file

@ -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");