Merge branch 'dev' into fix-i308
This commit is contained in:
commit
d5f01e80e1
@ -640,7 +640,7 @@ SC_FUNC void setlinedirect(int line);
|
|||||||
SC_FUNC void setlineconst(int line);
|
SC_FUNC void setlineconst(int line);
|
||||||
SC_FUNC void setlabel(int index);
|
SC_FUNC void setlabel(int index);
|
||||||
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
|
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
|
||||||
SC_FUNC void startfunc(char *fname);
|
SC_FUNC void startfunc(char *fname,int generateproc);
|
||||||
SC_FUNC void endfunc(void);
|
SC_FUNC void endfunc(void);
|
||||||
SC_FUNC void alignframe(int numbytes);
|
SC_FUNC void alignframe(int numbytes);
|
||||||
SC_FUNC void rvalue(value *lval);
|
SC_FUNC void rvalue(value *lval);
|
||||||
|
@ -3150,8 +3150,7 @@ SC_FUNC symbol *fetchfunc(char *name,int tag)
|
|||||||
sym=addsym(name,code_idx,iFUNCTN,sGLOBAL,tag,0);
|
sym=addsym(name,code_idx,iFUNCTN,sGLOBAL,tag,0);
|
||||||
assert(sym!=NULL); /* fatal error 103 must be given on error */
|
assert(sym!=NULL); /* fatal error 103 must be given on error */
|
||||||
/* assume no arguments */
|
/* assume no arguments */
|
||||||
sym->dim.arglist=(arginfo*)malloc(1*sizeof(arginfo));
|
sym->dim.arglist=(arginfo*)calloc(1,sizeof(arginfo));
|
||||||
sym->dim.arglist[0].ident=0;
|
|
||||||
/* set library ID to NULL (only for native functions) */
|
/* set library ID to NULL (only for native functions) */
|
||||||
sym->x.lib=NULL;
|
sym->x.lib=NULL;
|
||||||
/* set the required stack size to zero (only for non-native functions) */
|
/* set the required stack size to zero (only for non-native functions) */
|
||||||
@ -3799,7 +3798,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
|
|||||||
ptr=ptr->next;
|
ptr=ptr->next;
|
||||||
} /* while */
|
} /* while */
|
||||||
} /* if */
|
} /* if */
|
||||||
startfunc(sym->name); /* creates stack frame */
|
startfunc(sym->name,(sym->flags & flagNAKED)==0); /* creates stack frame */
|
||||||
insert_dbgline(funcline);
|
insert_dbgline(funcline);
|
||||||
setline(FALSE);
|
setline(FALSE);
|
||||||
if (sc_alignnext) {
|
if (sc_alignnext) {
|
||||||
@ -4224,8 +4223,12 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
|||||||
assert(numtags>0);
|
assert(numtags>0);
|
||||||
argsym=addvariable(name,offset,ident,sLOCAL,tags[0],
|
argsym=addvariable(name,offset,ident,sLOCAL,tags[0],
|
||||||
arg->dim,arg->numdim,arg->idxtag,0);
|
arg->dim,arg->numdim,arg->idxtag,0);
|
||||||
if (fpublic)
|
if (fpublic) {
|
||||||
argsym->usage|=uREAD; /* arguments of public functions are always "used" */
|
argsym->usage|=uREAD; /* arguments of public functions are always "used" */
|
||||||
|
if(argsym->ident==iREFARRAY || argsym->ident==iREFERENCE)
|
||||||
|
argsym->usage|=uWRITTEN;
|
||||||
|
}
|
||||||
|
|
||||||
if (fconst)
|
if (fconst)
|
||||||
argsym->usage|=uCONST;
|
argsym->usage|=uCONST;
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -4904,10 +4907,21 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
|
|||||||
error(204,sym->name); /* value assigned to symbol is never used */
|
error(204,sym->name); /* value assigned to symbol is never used */
|
||||||
errorset(sSETPOS,-1);
|
errorset(sSETPOS,-1);
|
||||||
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
|
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
|
||||||
|
int warn = 1;
|
||||||
|
symbol* depend = finddepend(sym);
|
||||||
|
while (depend != NULL) {
|
||||||
|
if ((depend->usage & (uWRITTEN | uPUBLIC | uCONST)) != 0) {
|
||||||
|
warn = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
depend = finddepend(depend);
|
||||||
|
} /* while */
|
||||||
|
if (warn) {
|
||||||
errorset(sSETPOS, sym->lnumber);
|
errorset(sSETPOS, sym->lnumber);
|
||||||
error(214, sym->name); /* make array argument "const" */
|
error(214, sym->name); /* make array argument "const" */
|
||||||
errorset(sSETPOS, -1);
|
errorset(sSETPOS, -1);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
} /* if */
|
||||||
/* also mark the variable (local or global) to the debug information */
|
/* also mark the variable (local or global) to the debug information */
|
||||||
if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0)
|
if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0)
|
||||||
insert_dbgsymbol(sym);
|
insert_dbgsymbol(sym);
|
||||||
|
@ -396,8 +396,11 @@ static void readline(unsigned char *line)
|
|||||||
*line='\0'; /* delete line */
|
*line='\0'; /* delete line */
|
||||||
cont=FALSE;
|
cont=FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* check whether to erase leading whitespace after '\\' on next line */
|
/* check whether to erase leading spaces */
|
||||||
if (cont) {
|
if (cont) {
|
||||||
|
unsigned char *ptr=line;
|
||||||
|
while (*ptr<=' ' && *ptr!='\0')
|
||||||
|
ptr++;
|
||||||
if (ptr!=line)
|
if (ptr!=line)
|
||||||
memmove(line,ptr,strlen((char*)ptr)+1);
|
memmove(line,ptr,strlen((char*)ptr)+1);
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -414,6 +417,10 @@ static void readline(unsigned char *line)
|
|||||||
ptr--; /* skip trailing whitespace */
|
ptr--; /* skip trailing whitespace */
|
||||||
if (*ptr=='\\') {
|
if (*ptr=='\\') {
|
||||||
cont=TRUE;
|
cont=TRUE;
|
||||||
|
/* set '\a' at the position of '\\' to make it possible to check
|
||||||
|
* for a line continuation in a single line comment (error 49)
|
||||||
|
*/
|
||||||
|
*ptr++='\a';
|
||||||
*ptr='\0'; /* erase '\n' (and any trailing whitespace) */
|
*ptr='\0'; /* erase '\n' (and any trailing whitespace) */
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -441,6 +448,7 @@ static void readline(unsigned char *line)
|
|||||||
static void stripcomment(unsigned char *line)
|
static void stripcomment(unsigned char *line)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
char* continuation;
|
||||||
#if !defined SC_LIGHT
|
#if !defined SC_LIGHT
|
||||||
#define COMMENT_LIMIT 100
|
#define COMMENT_LIMIT 100
|
||||||
#define COMMENT_MARGIN 40 /* length of the longest word */
|
#define COMMENT_MARGIN 40 /* length of the longest word */
|
||||||
@ -512,6 +520,24 @@ static void stripcomment(unsigned char *line)
|
|||||||
if (icomment==2)
|
if (icomment==2)
|
||||||
*line++=' ';
|
*line++=' ';
|
||||||
} else if (*line=='/' && *(line+1)=='/'){ /* comment to end of line */
|
} else if (*line=='/' && *(line+1)=='/'){ /* comment to end of line */
|
||||||
|
continuation=(char*)line;
|
||||||
|
while ((continuation=strchr(continuation,'\a'))!=NULL){
|
||||||
|
/* don't give the error if the next line is also commented out.
|
||||||
|
it is quite annoying to get an error for commenting out a define using:
|
||||||
|
|
||||||
|
//
|
||||||
|
// #define LONG_MACRO\
|
||||||
|
// did span \
|
||||||
|
// multiple lines
|
||||||
|
//
|
||||||
|
*/
|
||||||
|
while (*continuation<=' ' && *continuation!='\0')
|
||||||
|
continuation++; /* skip whitespace */
|
||||||
|
if (*continuation!='/' || *(continuation+1)!='/') {
|
||||||
|
error(49); /* invalid line continuation */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#if !defined SC_LIGHT
|
#if !defined SC_LIGHT
|
||||||
if (*(line+2)=='/' && *(line+3)<=' ') {
|
if (*(line+2)=='/' && *(line+3)<=' ') {
|
||||||
/* documentation comment */
|
/* documentation comment */
|
||||||
@ -903,6 +929,23 @@ static const unsigned char *getstring(unsigned char *dest,int max,const unsigned
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* strdupwithouta
|
||||||
|
*
|
||||||
|
* Duplicate a string, stripping out `\a`s.
|
||||||
|
*/
|
||||||
|
static char* strdupwithouta(const char* sourcestring)
|
||||||
|
{
|
||||||
|
char* result=strdup(sourcestring);
|
||||||
|
char* a=result;
|
||||||
|
if (result==NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
while ((a=strchr(a,'\a'))!=NULL) {
|
||||||
|
*a=' ';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CMD_NONE,
|
CMD_NONE,
|
||||||
CMD_TERM,
|
CMD_TERM,
|
||||||
@ -1115,7 +1158,7 @@ static int command(void)
|
|||||||
/* remove leading whitespace */
|
/* remove leading whitespace */
|
||||||
while (*lptr<=' ' && *lptr!='\0')
|
while (*lptr<=' ' && *lptr!='\0')
|
||||||
lptr++;
|
lptr++;
|
||||||
pc_deprecate=strdup((const char *)lptr);
|
pc_deprecate=strdupwithouta((const char *)lptr);
|
||||||
if (pc_deprecate!=NULL) {
|
if (pc_deprecate!=NULL) {
|
||||||
char *ptr=pc_deprecate+strlen(pc_deprecate)-1;
|
char *ptr=pc_deprecate+strlen(pc_deprecate)-1;
|
||||||
/* remove trailing whitespace */
|
/* remove trailing whitespace */
|
||||||
@ -1499,7 +1542,7 @@ static int command(void)
|
|||||||
while (*lptr<=' ' && *lptr!='\0')
|
while (*lptr<=' ' && *lptr!='\0')
|
||||||
lptr++;
|
lptr++;
|
||||||
if (!SKIPPING) {
|
if (!SKIPPING) {
|
||||||
char *usermsg=strdup((const char *)lptr);
|
char *usermsg=strdupwithouta((const char *)lptr);
|
||||||
if (usermsg!=NULL) {
|
if (usermsg!=NULL) {
|
||||||
char *ptr=usermsg+strlen(usermsg)-1;
|
char *ptr=usermsg+strlen(usermsg)-1;
|
||||||
/* remove trailing whitespace and newlines */
|
/* remove trailing whitespace and newlines */
|
||||||
@ -1893,6 +1936,10 @@ static const unsigned char *unpackedstring(const unsigned char *lptr,int *flags)
|
|||||||
while (*lptr==' ' || *lptr=='\t') /* this is as defines with parameters may add them */
|
while (*lptr==' ' || *lptr=='\t') /* this is as defines with parameters may add them */
|
||||||
lptr++; /* when you use a space after , in a match pattern */
|
lptr++; /* when you use a space after , in a match pattern */
|
||||||
while (*lptr!='\0') {
|
while (*lptr!='\0') {
|
||||||
|
if (*lptr=='\a') {
|
||||||
|
lptr++;
|
||||||
|
continue;
|
||||||
|
} /* if */
|
||||||
if (!instring) {
|
if (!instring) {
|
||||||
if (*lptr=='\"') {
|
if (*lptr=='\"') {
|
||||||
instring=1;
|
instring=1;
|
||||||
@ -1963,6 +2010,10 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
i=sizeof(ucell)-(sCHARBITS/8); /* start at most significant byte */
|
i=sizeof(ucell)-(sCHARBITS/8); /* start at most significant byte */
|
||||||
val=0;
|
val=0;
|
||||||
while (*lptr!='\0') {
|
while (*lptr!='\0') {
|
||||||
|
if (*lptr=='\a') { /* ignore '\a' (which was inserted at a line concatenation) */
|
||||||
|
lptr++;
|
||||||
|
continue;
|
||||||
|
} /* if */
|
||||||
if (!instring) {
|
if (!instring) {
|
||||||
if (*lptr=='\"') {
|
if (*lptr=='\"') {
|
||||||
instring=1;
|
instring=1;
|
||||||
|
@ -2216,7 +2216,7 @@ static int nesting=0;
|
|||||||
if (arg[argidx].numdim!=1) {
|
if (arg[argidx].numdim!=1) {
|
||||||
error(48); /* array dimensions must match */
|
error(48); /* array dimensions must match */
|
||||||
} else {
|
} else {
|
||||||
if (lval.sym==NULL && (arg[argidx].usage & uCONST)==0)
|
if (lval.sym==NULL && (arg[argidx].usage & uCONST)==0 && (sym->usage & uNATIVE)==0)
|
||||||
error(239);
|
error(239);
|
||||||
if (arg[argidx].dim[0]!=0) {
|
if (arg[argidx].dim[0]!=0) {
|
||||||
assert(arg[argidx].dim[0]>0);
|
assert(arg[argidx].dim[0]>0);
|
||||||
|
@ -343,9 +343,12 @@ SC_FUNC void markexpr(optmark type,const char *name,cell offset)
|
|||||||
*
|
*
|
||||||
* Global references: funcstatus (referred to only)
|
* Global references: funcstatus (referred to only)
|
||||||
*/
|
*/
|
||||||
SC_FUNC void startfunc(char *fname)
|
SC_FUNC void startfunc(char *fname,int generateproc)
|
||||||
{
|
{
|
||||||
|
if (generateproc) {
|
||||||
stgwrite("\tproc");
|
stgwrite("\tproc");
|
||||||
|
code_idx+=opcodes(1);
|
||||||
|
} /* if */
|
||||||
if (sc_asmfile) {
|
if (sc_asmfile) {
|
||||||
char symname[2*sNAMEMAX+16];
|
char symname[2*sNAMEMAX+16];
|
||||||
funcdisplayname(symname,fname);
|
funcdisplayname(symname,fname);
|
||||||
@ -353,7 +356,6 @@ SC_FUNC void startfunc(char *fname)
|
|||||||
stgwrite(symname);
|
stgwrite(symname);
|
||||||
} /* if */
|
} /* if */
|
||||||
stgwrite("\n");
|
stgwrite("\n");
|
||||||
code_idx+=opcodes(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* endfunc
|
/* endfunc
|
||||||
|
@ -20,8 +20,8 @@ set_tests_properties(gh_217 PROPERTIES PASS_REGULAR_EXPRESSION ".*\\.pwn\\(11\\)
|
|||||||
.*\\.pwn\\(13\\) : warning 237: user warning: this is warning 2
|
.*\\.pwn\\(13\\) : warning 237: user warning: this is warning 2
|
||||||
.*\\.pwn\\(15\\) : warning 237: user warning: this is warning 3
|
.*\\.pwn\\(15\\) : warning 237: user warning: this is warning 3
|
||||||
.*\\.pwn\\(17\\) : warning 237: user warning: this is warning 4
|
.*\\.pwn\\(17\\) : warning 237: user warning: this is warning 4
|
||||||
.*\\.pwn\\(27\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease
|
.*\\.pwn\\(28\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this function please
|
||||||
.*\\.pwn\\(32\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this functionplease
|
.*\\.pwn\\(33\\) : warning 234: function is deprecated \\(symbol \"f\"\\) don't use this function please
|
||||||
")
|
")
|
||||||
|
|
||||||
add_compiler_test(reset_errline_gh_230 ${CMAKE_CURRENT_SOURCE_DIR}/reset_errline_gh_230.pwn)
|
add_compiler_test(reset_errline_gh_230 ${CMAKE_CURRENT_SOURCE_DIR}/reset_errline_gh_230.pwn)
|
||||||
@ -60,6 +60,16 @@ set_tests_properties(constexpr_result_prop_gh_308 PROPERTIES PASS_REGULAR_EXPRES
|
|||||||
.*\\.pwn\\(14\\) : warning 237: user warning: \\\"Test passed.\\\"
|
.*\\.pwn\\(14\\) : warning 237: user warning: \\\"Test passed.\\\"
|
||||||
")
|
")
|
||||||
|
|
||||||
|
add_compiler_test(const_array_args_and_literals_gh_276 ${CMAKE_CURRENT_SOURCE_DIR}/const_array_args_and_literals_gh_276.pwn)
|
||||||
|
set_tests_properties(const_array_args_and_literals_gh_276 PROPERTIES PASS_REGULAR_EXPRESSION
|
||||||
|
".*\\.pwn\\(13\\) : warning 214: possibly a \\\"const\\\" array argument was intended: \\\"arr\\\"
|
||||||
|
.*\\.pwn\\(18\\) : warning 214: possibly a \\\"const\\\" array argument was intended: \\\"arr\\\"
|
||||||
|
.*\\.pwn\\(30\\) : warning 214: possibly a \\\"const\\\" array argument was intended: \\\"arr\\\"
|
||||||
|
.*\\.pwn\\(39\\) : warning 239: literal array/string passed to a non-const parameter
|
||||||
|
.*\\.pwn\\(40\\) : warning 239: literal array/string passed to a non-const parameter
|
||||||
|
.*\\.pwn\\(41\\) : warning 239: literal array/string passed to a non-const parameter
|
||||||
|
")
|
||||||
|
|
||||||
# Crashers
|
# Crashers
|
||||||
#
|
#
|
||||||
# These tests simply check that the compiler doesn't crash.
|
# These tests simply check that the compiler doesn't crash.
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
forward OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
|
||||||
|
|
||||||
|
native SetTimer(funcname[], interval, repeating);
|
||||||
|
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
f0(arr[]) {
|
||||||
|
#pragma unused arr
|
||||||
|
}
|
||||||
|
|
||||||
|
f1(arr[]) { // line 13
|
||||||
|
new a = arr[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
|
||||||
|
f2(arr[5]) {// line 18
|
||||||
|
new a = arr[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
f3(const arr[]) {
|
||||||
|
new a = arr[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
f4(const arr[5]) {
|
||||||
|
new a = arr[0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
f5(arr[][]) { // line 30
|
||||||
|
new a = arr[0][0];
|
||||||
|
#pragma unused a
|
||||||
|
}
|
||||||
|
f6(arr[][]) {
|
||||||
|
arr[0][0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
main () {
|
||||||
|
f0("test"); // line 39
|
||||||
|
f1("test"); // line 40
|
||||||
|
f2("test"); // line 41
|
||||||
|
f3("test");
|
||||||
|
f4("test");
|
||||||
|
|
||||||
|
new arr[5];
|
||||||
|
f1(arr);
|
||||||
|
f2(arr);
|
||||||
|
f3(arr);
|
||||||
|
f4(arr);
|
||||||
|
|
||||||
|
f1(arr[0]);
|
||||||
|
//f2(arr[0]); - array size must match
|
||||||
|
f3(arr[0]);
|
||||||
|
//f4(arr[0]); - array size must match
|
||||||
|
|
||||||
|
new arr2[1][1];
|
||||||
|
f5(arr2);
|
||||||
|
f6(arr2);
|
||||||
|
|
||||||
|
SetTimer("test", 0, 0);
|
||||||
|
}
|
@ -17,7 +17,8 @@ warning 3
|
|||||||
warning 4
|
warning 4
|
||||||
|
|
||||||
// single-line comments can span \
|
// single-line comments can span \
|
||||||
multiple lines if you really want it
|
//multiple lines if you really want it
|
||||||
|
// no they can't, only with more //s.
|
||||||
|
|
||||||
#pragma deprecated don't\
|
#pragma deprecated don't\
|
||||||
use \
|
use \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user