Fix clang warnings
This commit is contained in:
parent
8495645423
commit
3a4878f54b
@ -1496,7 +1496,7 @@ static void setconstants(void)
|
||||
#endif
|
||||
add_builtin_constant("charbits",sCHARBITS,sGLOBAL,0);
|
||||
add_builtin_constant("charmin",0,sGLOBAL,0);
|
||||
add_builtin_constant("charmax",~(-1 << sCHARBITS) - 1,sGLOBAL,0);
|
||||
add_builtin_constant("charmax",~((ucell)-1 << sCHARBITS) - 1,sGLOBAL,0);
|
||||
add_builtin_constant("ucharmax",(1 << (sizeof(cell)-1)*8)-1,sGLOBAL,0);
|
||||
|
||||
add_builtin_constant("__Pawn",VERSION_INT,sGLOBAL,0);
|
||||
@ -2207,7 +2207,7 @@ static int declloc(int fstatic)
|
||||
* of a global variable or to that of a local variable at a lower
|
||||
* level might indicate a bug.
|
||||
*/
|
||||
if ((sym=findloc(name))!=NULL && sym->compound!=nestlevel || findglb(name,sGLOBAL)!=NULL)
|
||||
if (((sym=findloc(name))!=NULL && sym->compound!=nestlevel) || findglb(name,sGLOBAL)!=NULL)
|
||||
error(219,name); /* variable shadows another symbol */
|
||||
while (matchtoken('[')){
|
||||
ident=iARRAY;
|
||||
@ -3215,7 +3215,7 @@ static int operatoradjust(int opertok,symbol *sym,char *opername,int resulttag)
|
||||
error(62); /* number or placement of the operands does not fit the operator */
|
||||
} /* switch */
|
||||
|
||||
if (tags[0]==0 && (opertok!='=' && tags[1]==0 || opertok=='=' && resulttag==0))
|
||||
if (tags[0]==0 && ((opertok!='=' && tags[1]==0) || (opertok=='=' && resulttag==0)))
|
||||
error(64); /* cannot change predefined operators */
|
||||
|
||||
/* change the operator name */
|
||||
@ -3415,7 +3415,7 @@ static void funcstub(int fnative)
|
||||
tok=lex(&val,&str);
|
||||
fpublic=(tok==tPUBLIC) || (tok==tSYMBOL && str[0]==PUBLIC_CHAR);
|
||||
if (fnative) {
|
||||
if (fpublic || tok==tSTOCK || tok==tSTATIC || tok==tSYMBOL && *str==PUBLIC_CHAR)
|
||||
if (fpublic || tok==tSTOCK || tok==tSTATIC || (tok==tSYMBOL && *str==PUBLIC_CHAR))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
} else {
|
||||
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC)
|
||||
@ -3540,7 +3540,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
|
||||
tag= (firsttag>=0) ? firsttag : pc_addtag(NULL);
|
||||
tok=lex(&val,&str);
|
||||
assert(!fpublic);
|
||||
if (tok==tNATIVE || tok==tPUBLIC && stock)
|
||||
if (tok==tNATIVE || (tok==tPUBLIC && stock))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
if (tok==tOPERATOR) {
|
||||
opertok=operatorname(symbolname);
|
||||
@ -3889,7 +3889,7 @@ static int declargs(symbol *sym,int chkshadow)
|
||||
error(10); /* illegal function or declaration */
|
||||
} /* switch */
|
||||
} while (tok=='&' || tok==tLABEL || tok==tCONST
|
||||
|| tok!=tELLIPS && matchtoken(',')); /* more? */
|
||||
|| (tok!=tELLIPS && matchtoken(','))); /* more? */
|
||||
/* if the next token is not ",", it should be ")" */
|
||||
needtoken(')');
|
||||
} /* if */
|
||||
@ -4995,7 +4995,6 @@ SC_FUNC symbol *add_builtin_string_constant(char *name,const char *val,
|
||||
if (sym==NULL)
|
||||
sym=findloc(name);
|
||||
if (sym!=NULL) {
|
||||
int redef=0;
|
||||
if (sym->ident!=iARRAY) {
|
||||
error(21,name); /* symbol already defined */
|
||||
return NULL;
|
||||
@ -5825,7 +5824,7 @@ static void doreturn(void)
|
||||
if ((rettype & uRETVALUE)!=0) {
|
||||
int retarray=(ident==iARRAY || ident==iREFARRAY);
|
||||
/* there was an earlier "return" statement in this function */
|
||||
if ((sub==NULL && retarray && sym!=NULL) || sub!=NULL && !retarray)
|
||||
if ((sub==NULL && retarray && sym!=NULL) || (sub!=NULL && !retarray))
|
||||
error(79); /* mixing "return array;" and "return value;" */
|
||||
if (retarray && (curfunc->usage & uPUBLIC)!=0)
|
||||
error(90,curfunc->name); /* public function may not return array */
|
||||
@ -5836,7 +5835,7 @@ static void doreturn(void)
|
||||
if (!matchtag(curfunc->tag,tag,TRUE))
|
||||
error(213); /* tagname mismatch */
|
||||
if (ident==iARRAY || ident==iREFARRAY) {
|
||||
int dim[sDIMEN_MAX],numdim;
|
||||
int dim[sDIMEN_MAX],numdim=0;
|
||||
cell arraysize;
|
||||
if (sym==NULL) {
|
||||
/* array literals cannot be returned directly */
|
||||
|
@ -482,7 +482,7 @@ static void stripcom(unsigned char *line)
|
||||
#if !defined SC_LIGHT
|
||||
/* collect the comment characters in a string */
|
||||
if (icomment==2) {
|
||||
if (skipstar && (*line!='\0' && *line<=' ' || *line=='*')) {
|
||||
if (skipstar && ((*line!='\0' && *line<=' ') || *line=='*')) {
|
||||
/* ignore leading whitespace and '*' characters */
|
||||
} else if (commentidx<COMMENT_LIMIT+COMMENT_MARGIN-1) {
|
||||
comment[commentidx++]=(char)((*line!='\n') ? *line : ' ');
|
||||
@ -1312,7 +1312,7 @@ static int command(void)
|
||||
sym=findloc(str);
|
||||
if (sym==NULL)
|
||||
sym=findglb(str,sSTATEVAR);
|
||||
if (sym==NULL || sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0) {
|
||||
if (sym==NULL || (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0)) {
|
||||
error(17,str); /* undefined symbol */
|
||||
} else {
|
||||
if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
|
||||
@ -1784,7 +1784,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
|
||||
if (strncmp((char*)start,"defined",7)==0 && *(start+7)<=' ') {
|
||||
start+=7; /* skip "defined" */
|
||||
/* skip white space & parantheses */
|
||||
while (*start<=' ' && *start!='\0' || *start=='(')
|
||||
while ((*start<=' ' && *start!='\0') || *start=='(')
|
||||
start++;
|
||||
/* skip the symbol behind it */
|
||||
while (alphanum(*start))
|
||||
@ -2198,7 +2198,7 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
error(220);
|
||||
} /* if */
|
||||
} /* if */
|
||||
} else if (*lptr=='\"' || *lptr=='#' || *lptr==sc_ctrlchar && (*(lptr+1)=='\"' || *(lptr+1)=='#'))
|
||||
} else if (*lptr=='\"' || *lptr=='#' || (*lptr==sc_ctrlchar && (*(lptr+1)=='\"' || *(lptr+1)=='#')))
|
||||
{ /* unpacked string literal */
|
||||
_lextok=tSTRING;
|
||||
stringflags=(*lptr==sc_ctrlchar) ? RAWMODE : 0;
|
||||
@ -2212,9 +2212,9 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
lptr+=1; /* skip final quote */
|
||||
else if (!(stringflags & STRINGIZE))
|
||||
error(37); /* invalid (non-terminated) string */
|
||||
} else if (*lptr=='!' && (*(lptr+1)=='\"' || *(lptr+1)=='#')
|
||||
|| *lptr=='!' && *(lptr+1)==sc_ctrlchar && (*(lptr+2)=='\"' || *(lptr+2)=='#')
|
||||
|| *lptr==sc_ctrlchar && *(lptr+1)=='!' && (*(lptr+2)=='\"' || *(lptr+2)=='#'))
|
||||
} else if ((*lptr=='!' && (*(lptr+1)=='\"' || *(lptr+1)=='#'))
|
||||
|| (*lptr=='!' && *(lptr+1)==sc_ctrlchar && (*(lptr+2)=='\"' || *(lptr+2)=='#'))
|
||||
|| (*lptr==sc_ctrlchar && *(lptr+1)=='!' && (*(lptr+2)=='\"' || *(lptr+2)=='#')))
|
||||
{ /* packed string literal */
|
||||
_lextok=tSTRING;
|
||||
stringflags=0;
|
||||
@ -2312,7 +2312,7 @@ SC_FUNC int matchtoken(int token)
|
||||
int tok;
|
||||
|
||||
tok=lex(&val,&str);
|
||||
if (tok==token || token==tTERM && (tok==';' || tok==tENDEXPR)) {
|
||||
if (tok==token || (token==tTERM && (tok==';' || tok==tENDEXPR))) {
|
||||
return 1;
|
||||
} else if (!sc_needsemicolon && token==tTERM && (_lexnewline || !freading)) {
|
||||
/* Push "tok" back, because it is the token following the implicit statement
|
||||
@ -2799,8 +2799,8 @@ static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int a
|
||||
{
|
||||
assert(sym->states==NULL || sym->states->next!=NULL); /* first element of the state list is the "root" */
|
||||
if (sym->ident==iFUNCTN
|
||||
|| automaton<0 && sym->states==NULL
|
||||
|| automaton>=0 && sym->states!=NULL && state_getfsa(sym->states->next->index)==automaton)
|
||||
|| (automaton<0 && sym->states==NULL)
|
||||
|| (automaton>=0 && sym->states!=NULL && state_getfsa(sym->states->next->index)==automaton))
|
||||
{
|
||||
if (cmptag==NULL && sym->fnumber==fnumber)
|
||||
return sym; /* return first match */
|
||||
|
@ -592,8 +592,8 @@ static void plnge2(void (*oper)(void),
|
||||
* has no side effects. This may not be accurate, but it does allow
|
||||
* the compiler to check the effect of the entire expression.
|
||||
*/
|
||||
if (lval1->sym!=NULL && (lval1->sym->ident==iFUNCTN || lval1->sym->ident==iREFFUNC)
|
||||
|| lval2->sym!=NULL && (lval2->sym->ident==iFUNCTN || lval2->sym->ident==iREFFUNC))
|
||||
if ((lval1->sym!=NULL && (lval1->sym->ident==iFUNCTN || lval1->sym->ident==iREFFUNC))
|
||||
|| (lval2->sym!=NULL && (lval2->sym->ident==iFUNCTN || lval2->sym->ident==iREFFUNC)))
|
||||
pc_sideeffect=FALSE;
|
||||
if (lval1->ident==iARRAY || lval1->ident==iREFARRAY) {
|
||||
char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-";
|
||||
@ -820,7 +820,7 @@ static int hier14(value *lval1)
|
||||
* negative value would do).
|
||||
*/
|
||||
for (i=0; i<sDIMEN_MAX; i++)
|
||||
arrayidx1[i]=arrayidx2[i]=(cell)(-1L << (sizeof(cell)*8-1));
|
||||
arrayidx1[i]=arrayidx2[i]=(cell)CELL_MAX;
|
||||
org_arrayidx=lval1->arrayidx; /* save current pointer, to reset later */
|
||||
if (lval1->arrayidx==NULL)
|
||||
lval1->arrayidx=arrayidx1;
|
||||
@ -1001,7 +1001,7 @@ static int hier14(value *lval1)
|
||||
} /* if */
|
||||
if (lval3.sym->dim.array.level!=level)
|
||||
return error(48); /* array dimensions must match */
|
||||
else if (ltlength<val || exactmatch && ltlength>val || val==0)
|
||||
else if (ltlength<val || (exactmatch && ltlength>val) || val==0)
|
||||
return error(47); /* array sizes must match */
|
||||
else if (lval3.ident!=iARRAYCELL && !matchtag(lval3.sym->x.tags.index,idxtag,TRUE))
|
||||
error(229,(lval2.sym!=NULL) ? lval2.sym->name : lval3.sym->name); /* index tag mismatch */
|
||||
@ -1588,7 +1588,7 @@ restart:
|
||||
} /* if */
|
||||
if (close==']') {
|
||||
/* normal array index */
|
||||
if (lval2.constval<0 || sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval)
|
||||
if (lval2.constval<0 || (sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval))
|
||||
error(32,sym->name); /* array index out of bounds */
|
||||
if (lval2.constval!=0) {
|
||||
/* don't add offsets for zero subscripts */
|
||||
@ -1605,8 +1605,9 @@ restart:
|
||||
} /* if */
|
||||
} else {
|
||||
/* character index */
|
||||
if (lval2.constval<0 || sym->dim.array.length!=0
|
||||
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval)
|
||||
if (lval2.constval<0
|
||||
|| (sym->dim.array.length!=0
|
||||
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval))
|
||||
error(32,sym->name); /* array index out of bounds */
|
||||
if (lval2.constval!=0) {
|
||||
/* don't add offsets for zero subscripts */
|
||||
@ -2197,8 +2198,8 @@ static int nesting=0;
|
||||
* function argument; a literal string may be smaller than
|
||||
* the function argument.
|
||||
*/
|
||||
if (lval.constval>0 && arg[argidx].dim[0]!=lval.constval
|
||||
|| lval.constval<0 && arg[argidx].dim[0] < -lval.constval)
|
||||
if ((lval.constval>0 && arg[argidx].dim[0]!=lval.constval)
|
||||
|| (lval.constval<0 && arg[argidx].dim[0] < -lval.constval))
|
||||
error(47); /* array sizes must match */
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
@ -249,7 +249,7 @@ SC_FUNC void setline(int chkbounds)
|
||||
stgwrite("\t; line ");
|
||||
outval(fline,TRUE);
|
||||
} /* if */
|
||||
if ((sc_debug & sSYMBOLIC)!=0 || chkbounds && (sc_debug & sCHKBOUNDS)!=0) {
|
||||
if ((sc_debug & sSYMBOLIC)!=0 || (chkbounds && (sc_debug & sCHKBOUNDS)!=0)) {
|
||||
/* generate a "break" (start statement) opcode rather than a "line" opcode
|
||||
* because earlier versions of Small/Pawn have an incompatible version of the
|
||||
* line opcode
|
||||
@ -775,7 +775,7 @@ SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
|
||||
stgwrite(sym->name);
|
||||
} /* if */
|
||||
if (sc_asmfile
|
||||
&& (label!=NULL || !isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar))
|
||||
&& (label!=NULL || (!isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar)))
|
||||
{
|
||||
stgwrite("\t; ");
|
||||
stgwrite(symname);
|
||||
|
@ -283,7 +283,7 @@ static short lastfile;
|
||||
} /* if */
|
||||
va_end(argptr);
|
||||
|
||||
if (number>=100 && number<200 || errnum>25){
|
||||
if ((number>=100 && number<200) || errnum>25){
|
||||
if (strlen(errfname)==0) {
|
||||
va_start(argptr,number);
|
||||
pc_error(0,"\nCompilation aborted.\n\n",NULL,0,0,argptr);
|
||||
|
@ -218,9 +218,9 @@ static char *stripwhitespace(char *str)
|
||||
if (*str!='\0') {
|
||||
size_t len = strlen(str);
|
||||
size_t i;
|
||||
for (i=len-1; i>=0; i--) {
|
||||
if (!isspace(str[i])) {
|
||||
str[i+1]='\0';
|
||||
for (i=len; i>=1; i--) {
|
||||
if (!isspace(str[i-1])) {
|
||||
str[i]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
instr=skipwhitespace(line);
|
||||
/* ignore empty lines and labels (labels have a special syntax, so these
|
||||
* must be parsed separately) */
|
||||
if (*instr=='\0' || tolower(*instr)=='l' && *(instr+1)=='.')
|
||||
if (*instr=='\0' || (tolower(*instr)=='l') && *(instr+1)=='.')
|
||||
continue;
|
||||
/* get to the end of the instruction (make use of the '\n' that fgets()
|
||||
* added at the end of the line; this way we will *always* drop on a
|
||||
|
@ -1642,7 +1642,7 @@ static int matchsequence(char *start,char *end,char *pattern,
|
||||
assert(*(start+1)=='\0');
|
||||
start+=2; /* skip '\n' and '\0' */
|
||||
if (*(pattern+1)!='\0')
|
||||
while (start<end && *start=='\t' || *start==' ')
|
||||
while ((start<end && *start=='\t') || *start==' ')
|
||||
start++; /* skip leading white space of next instruction */
|
||||
break;
|
||||
default:
|
||||
@ -1691,8 +1691,10 @@ static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+
|
||||
} /* while */
|
||||
|
||||
/* allocate a buffer to replace the sequence in */
|
||||
if ((buffer=(char*)malloc(*repl_length))==NULL)
|
||||
return (char*)error(103);
|
||||
if ((buffer=(char*)malloc(*repl_length))==NULL) {
|
||||
error(103);
|
||||
return NULL;
|
||||
} /* if */
|
||||
|
||||
/* replace the pattern into this temporary buffer */
|
||||
lptr=buffer;
|
||||
|
@ -339,7 +339,7 @@ SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **end
|
||||
/* the code positions 0xd800--0xdfff and 0xfffe & 0xffff do not
|
||||
* exist in UCS-4 (and hence, they do not exist in Unicode)
|
||||
*/
|
||||
if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
|
||||
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
|
||||
return -1;
|
||||
} /* if */
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user