Compiler: Add #pragma deprecated.

This is based on SM, including patch to support macros/constants (https://hg.alliedmods.net/sourcemod-central/rev/ef8dd1cddc35).
Updated also some pawn includes to use this new pragma.
This commit is contained in:
Arkshine
2014-08-13 13:18:33 +02:00
parent 09303625fb
commit 520493fab1
11 changed files with 5685 additions and 5613 deletions

View File

@@ -276,6 +276,26 @@ SC_FUNC stringpair *insert_subst(char *pattern,char *substitution,int prefixlen)
if ((cur=insert_stringpair(&substpair,pattern,substitution,prefixlen))==NULL)
error(103); /* insufficient memory (fatal error) */
adjustindex(*pattern);
if (pc_deprecate != NULL) {
assert(cur != NULL);
cur->flags |= flgDEPRECATED;
if (sc_status == statWRITE) {
if (cur->documentation != NULL) {
free(cur->documentation);
cur->documentation = NULL;
} /* if */
cur->documentation = pc_deprecate;
}
else {
free(pc_deprecate);
} /* if */
pc_deprecate = NULL;
}
else {
cur->flags = 0;
cur->documentation = NULL;
} /* if */
return cur;
}
@@ -288,6 +308,24 @@ SC_FUNC stringpair *find_subst(char *name,int length)
item=substindex[(int)*name-'A'];
if (item!=NULL)
item=find_stringpair(item,name,length);
if (item && (item->flags & flgDEPRECATED) != 0)
{
static char macro[128];
char *rem, *msg = (item->documentation != NULL) ? item->documentation : "";
strncpy(macro, item->first, sizeof(macro));
macro[sizeof(macro) - 1] = '\0';
/* If macro contains an opening parentheses and a percent sign, then assume that
* it takes arguments and remove them from the warning message.
*/
if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem)
{
*rem = '\0';
}
error(233, macro, msg); /* deprecated (macro/constant) */
}
return item;
}