Add proper support for negative constants in external initialisers.

This commit is contained in:
David Given 2017-01-01 17:56:53 +00:00
parent 049aff9f33
commit 8b8910595a

View file

@ -542,6 +542,7 @@ extdef(void)
int o, dim, i; int o, dim, i;
char *bs; char *bs;
char *ms; char *ms;
int neg;
if ((o = symbol()) == EOFC || o == SEMI) if ((o = symbol()) == EOFC || o == SEMI)
return; return;
@ -549,6 +550,7 @@ extdef(void)
goto syntax; goto syntax;
bs = bsym->name; bs = bsym->name;
i = dim = 0; i = dim = 0;
neg = 0;
switch(o = symbol()) { switch(o = symbol()) {
case SEMI: case SEMI:
@ -560,9 +562,16 @@ extdef(void)
/* init */ /* init */
case CON: case CON:
case STRING: case STRING:
case MINUS:
global(bs); global(bs);
if (o == STRING) if (o == STRING)
bsymb(bs); bsymb(bs);
else if (o == MINUS) {
o = symbol();
if (o != CON)
goto syntax;
cval = -cval;
}
C_df_dnam(manglename(bs, 'b')); C_df_dnam(manglename(bs, 'b'));
pushsym(o); pushsym(o);
goto init; goto init;