Merge branch 'pr-128' (#128)

Fixes #119, #125.
This commit is contained in:
Zeex 2017-01-17 23:43:31 +06:00
commit 6a3ab7c9f4
3 changed files with 32 additions and 18 deletions

View File

@ -4690,7 +4690,7 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
/* a variable */
if (sym->parent!=NULL)
break; /* hierarchical data type */
if ((sym->usage & (uWRITTEN | uREAD | uSTOCK))==0) {
if ((sym->usage & (uWRITTEN | uREAD | uSTOCK | uPUBLIC))==0) {
if (testconst)
errorset(sSETPOS,sym->lnumber);
error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */

View File

@ -1343,8 +1343,19 @@ static int command(void)
} /* if */
break;
default: {
char s2[20];
extern char *sc_tokens[];/* forward declaration */
char s2[33]="-";
if ((char)tok=='-') {
if (lex(&val,&str)==tNUMBER) {
outval(-val,FALSE);
code_idx+=opargs(1);
break;
} else {
strcpy(s2+1, str);
error(1,sc_tokens[tSYMBOL-tFIRST],s2);
break;
} /* if */
} /* if */
if (tok<256)
sprintf(s2,"%c",(char)tok);
else

View File

@ -160,26 +160,26 @@ static uint32_t *align32(uint32_t *v)
#if PAWN_CELL_SIZE>=64
static uint64_t *align64(uint64_t *v)
{
unsigned char *s = (unsigned char *)v;
unsigned char t;
unsigned char *s = (unsigned char *)v;
unsigned char t;
t=s[0];
s[0]=s[7];
s[7]=t;
t=s[0];
s[0]=s[7];
s[7]=t;
t=s[1];
s[1]=s[6];
s[6]=t;
t=s[1];
s[1]=s[6];
s[6]=t;
t=s[2];
s[2]=s[5];
s[5]=t;
t=s[2];
s[2]=s[5];
s[5]=t;
t=s[3];
s[3]=s[4];
s[4]=t;
t=s[3];
s[3]=s[4];
s[4]=t;
return v;
return v;
}
#endif
@ -747,7 +747,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
mainaddr=sym->addr;
} /* if */
} else if (sym->ident==iVARIABLE) {
if ((sym->usage & uPUBLIC)!=0)
if ((sym->usage & uPUBLIC)!=0
&& ((sym->usage & uSTOCK)==0 || (sym->usage & (uREAD | uWRITTEN))!=0))
match=++numpubvars;
} /* if */
if (match) {
@ -925,6 +926,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
count=0;
for (sym=glbtab.next; sym!=NULL; sym=sym->next) {
if (sym->ident==iVARIABLE && (sym->usage & uPUBLIC)!=0) {
if ((sym->usage & uSTOCK)!=0 && (sym->usage & (uREAD | uWRITTEN))==0)
continue;
assert((sym->usage & uDEFINE)!=0);
assert(sym->vclass==sGLOBAL);
func.address=sym->addr;