From 3509f963ee59085753f3ee136db21a0ce00311c2 Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Thu, 5 Mar 2015 18:45:15 -0600 Subject: [PATCH] Improve the diagnostic given when a function prototype doesn't match an existing definition. --- sourcepawn/compiler/sc.h | 2 +- sourcepawn/compiler/sc1.cpp | 4 ++-- sourcepawn/compiler/sc5-in.scp | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index c2407efd..9399ed47 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -981,7 +981,7 @@ typedef struct array_info_s } array_info_t; enum FatalError { - FIRST_FATAL_ERROR = 180, + FIRST_FATAL_ERROR = 182, FATAL_ERROR_READ = FIRST_FATAL_ERROR, FATAL_ERROR_WRITE, diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 34e760e9..6fa858d4 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -5535,7 +5535,7 @@ static int newfunc(declinfo_t *decl, const int *thistag, int fpublic, int fstati if ((sym->usage & uPROTOTYPED) && !compare_tag(sym->tag, decl->type.tag)) { int old_fline = fline; fline = funcline; - error(25); + error(180, type_to_name(sym->tag), type_to_name(decl->type.tag)); fline = old_fline; } @@ -5745,7 +5745,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag) } else { /* check the argument with the earlier definition */ if (argcnt>oldargcnt || !argcompare(&sym->dim.arglist[argcnt],&arg)) - error(25); /* function definition does not match prototype */ + error(181, arg.name); /* function argument does not match prototype */ /* may need to free default array argument and the tag list */ if (arg.ident==iREFARRAY && arg.hasdefault) free(arg.defvalue.array.data); diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 0c8d1528..75025e2d 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -222,7 +222,9 @@ static const char *errmsg[] = { /*176*/ "non-static method or property '%s' must be called with a value of type '%s'\n", /*177*/ "static method '%s' must be invoked via its type (try '%s.%s')\n", /*178*/ "cannot coerce %s[] to %s[]; storage classes differ\n", -/*179*/ "cannot assign %s[] to %s[], storage classes differ\n", +/*179*/ "cannot assign %s[] to %s[], storage classes differ\n", +/*180*/ "function return type differs from prototype. expected '%s', but got '%s'\n", +/*181*/ "function argument named '%s' differs from prototype\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", @@ -386,24 +388,24 @@ static const char *errmsg[] = { static const char *fatalmsg[] = { #ifdef SCPACK -/*180*/ "cannot read from file: \"%s\"\n", -/*181*/ "cannot write to file: \"%s\"\n", -/*182*/ "table overflow: \"%s\"\n", +/*182*/ "cannot read from file: \"%s\"\n", +/*183*/ "cannot write to file: \"%s\"\n", +/*184*/ "table overflow: \"%s\"\n", /* table can be: loop table * literal table * staging buffer * option table (response file) * peephole optimizer table */ -/*183*/ "insufficient memory\n", -/*184*/ "invalid assembler instruction \"%s\"\n", -/*185*/ "numeric overflow, exceeding capacity\n", -/*186*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", -/*187*/ "too many error messages on one line\n", -/*188*/ "codepage mapping file not found\n", -/*189*/ "invalid path: \"%s\"\n", -/*190*/ "assertion failed: %s\n", -/*191*/ "user error: %s\n", +/*185*/ "insufficient memory\n", +/*186*/ "invalid assembler instruction \"%s\"\n", +/*187*/ "numeric overflow, exceeding capacity\n", +/*188*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", +/*189*/ "too many error messages on one line\n", +/*190*/ "codepage mapping file not found\n", +/*191*/ "invalid path: \"%s\"\n", +/*192*/ "assertion failed: %s\n", +/*193*/ "user error: %s\n", #else "\256\214a\204from \344le:\354", "\256writ\200\266 \344le:\354",