many minor modifications (it still will not fit on Minix!)
This commit is contained in:
parent
35c612b99b
commit
e4857c2446
|
@ -124,6 +124,7 @@
|
||||||
!File: spec_arith.h
|
!File: spec_arith.h
|
||||||
/* describes internal compiler arithmetics */
|
/* describes internal compiler arithmetics */
|
||||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||||
|
#undef UNSIGNED_ARITH unsigned arith
|
||||||
|
|
||||||
|
|
||||||
!File: static.h
|
!File: static.h
|
||||||
|
|
|
@ -535,7 +535,7 @@ string_token(nm, stop_char, plen)
|
||||||
ch = quoted(GetChar());
|
ch = quoted(GetChar());
|
||||||
str[pos++] = ch;
|
str[pos++] = ch;
|
||||||
if (pos == str_size)
|
if (pos == str_size)
|
||||||
str = Srealloc(str, (unsigned) (str_size += RSTRSIZE));
|
str = Realloc(str, (unsigned) (str_size += RSTRSIZE));
|
||||||
ch = GetChar();
|
ch = GetChar();
|
||||||
}
|
}
|
||||||
str[pos++] = '\0'; /* for filenames etc. */
|
str[pos++] = '\0'; /* for filenames etc. */
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
!File: spec_arith.h
|
!File: spec_arith.h
|
||||||
/* describes internal compiler arithmetics */
|
/* describes internal compiler arithmetics */
|
||||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||||
|
#undef UNSIGNED_ARITH unsigned arith
|
||||||
|
|
||||||
|
|
||||||
!File: static.h
|
!File: static.h
|
||||||
|
|
|
@ -416,14 +416,14 @@ check_pseudoproto(pl, opl)
|
||||||
|
|
||||||
if (pl->pl_flag & PL_ELLIPSIS) {
|
if (pl->pl_flag & PL_ELLIPSIS) {
|
||||||
error("illegal ellipsis terminator");
|
error("illegal ellipsis terminator");
|
||||||
return 2;
|
return 0;
|
||||||
}
|
}
|
||||||
if (opl->pl_flag & PL_VOID) {
|
if (opl->pl_flag & PL_VOID) {
|
||||||
if (!(pl->pl_flag & PL_VOID))
|
if (!(pl->pl_flag & PL_VOID))
|
||||||
error("function is defined without parameters");
|
error("function is defined without parameters");
|
||||||
pl->pl_flag |= PL_ERRGIVEN;
|
pl->pl_flag |= PL_ERRGIVEN;
|
||||||
opl->pl_flag |= PL_ERRGIVEN;
|
opl->pl_flag |= PL_ERRGIVEN;
|
||||||
return 2;
|
return 0;
|
||||||
}
|
}
|
||||||
while (pl && opl) {
|
while (pl && opl) {
|
||||||
if (!equal_type(pl->pl_type, opl->pl_type, 0)) {
|
if (!equal_type(pl->pl_type, opl->pl_type, 0)) {
|
||||||
|
@ -433,14 +433,14 @@ check_pseudoproto(pl, opl)
|
||||||
opl->pl_idf->id_text);
|
opl->pl_idf->id_text);
|
||||||
pl->pl_flag |= PL_ERRGIVEN;
|
pl->pl_flag |= PL_ERRGIVEN;
|
||||||
opl->pl_flag |= PL_ERRGIVEN;
|
opl->pl_flag |= PL_ERRGIVEN;
|
||||||
retval = 2;
|
retval = 0;
|
||||||
}
|
}
|
||||||
pl = pl->next;
|
pl = pl->next;
|
||||||
opl = opl->next;
|
opl = opl->next;
|
||||||
}
|
}
|
||||||
if (pl || opl) {
|
if (pl || opl) {
|
||||||
error("incorrect number of parameters");
|
error("incorrect number of parameters");
|
||||||
retval = 2;
|
retval = 0;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -468,10 +468,9 @@ legal_mixture(tp, otp)
|
||||||
if (pl)
|
if (pl)
|
||||||
error("illegal ellipsis terminator");
|
error("illegal ellipsis terminator");
|
||||||
else error("ellipsis terminator in previous (prototype) declaration");
|
else error("ellipsis terminator in previous (prototype) declaration");
|
||||||
|
prot->pl_flag |= PL_ERRGIVEN;
|
||||||
}
|
}
|
||||||
prot->pl_flag |= PL_ERRGIVEN;
|
return 0;
|
||||||
prot = prot->next;
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
while (prot) {
|
while (prot) {
|
||||||
/* if (!(prot->pl_flag & PL_ELLIPSIS)) {} */
|
/* if (!(prot->pl_flag & PL_ELLIPSIS)) {} */
|
||||||
|
@ -481,7 +480,7 @@ legal_mixture(tp, otp)
|
||||||
error("illegal %s parameter in %sdeclaration",
|
error("illegal %s parameter in %sdeclaration",
|
||||||
symbol2str(fund), (opl ? "previous (prototype) " : "" ));
|
symbol2str(fund), (opl ? "previous (prototype) " : "" ));
|
||||||
prot->pl_flag |= PL_ERRGIVEN;
|
prot->pl_flag |= PL_ERRGIVEN;
|
||||||
retval = 2;
|
retval = 0;
|
||||||
}
|
}
|
||||||
prot = prot->next;
|
prot = prot->next;
|
||||||
}
|
}
|
||||||
|
@ -500,10 +499,8 @@ equal_proto(pl, opl)
|
||||||
*/
|
*/
|
||||||
while ( pl && opl) {
|
while ( pl && opl) {
|
||||||
|
|
||||||
if ((pl->pl_flag & ~PL_ERRGIVEN) != (opl->pl_flag & ~PL_ERRGIVEN))
|
if ((pl->pl_flag & ~PL_ERRGIVEN) != (opl->pl_flag & ~PL_ERRGIVEN) ||
|
||||||
return 0;
|
!equal_type(pl->pl_type, opl->pl_type, 0))
|
||||||
|
|
||||||
if (!equal_type(pl->pl_type, opl->pl_type, 0))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pl = pl->next;
|
pl = pl->next;
|
||||||
|
@ -519,7 +516,6 @@ struct type *tp;
|
||||||
register struct sdef *sdf;
|
register struct sdef *sdf;
|
||||||
|
|
||||||
ASSERT(tp);
|
ASSERT(tp);
|
||||||
if (!tp) return 0;
|
|
||||||
if (tp->tp_typequal & TQ_CONST) return 1;
|
if (tp->tp_typequal & TQ_CONST) return 1;
|
||||||
sdf = tp->tp_sdef;
|
sdf = tp->tp_sdef;
|
||||||
while (sdf) {
|
while (sdf) {
|
||||||
|
|
|
@ -35,13 +35,15 @@ ch3bin(expp, oper, expr)
|
||||||
/* apply binary operator oper between *expp and expr.
|
/* apply binary operator oper between *expp and expr.
|
||||||
NB: don't swap operands if op is one of the op= operators!!!
|
NB: don't swap operands if op is one of the op= operators!!!
|
||||||
*/
|
*/
|
||||||
|
register struct type *expp_tp;
|
||||||
|
|
||||||
any2opnd(expp, oper);
|
any2opnd(expp, oper);
|
||||||
|
expp_tp = (*expp)->ex_type;
|
||||||
any2opnd(&expr, oper);
|
any2opnd(&expr, oper);
|
||||||
switch (oper) {
|
switch (oper) {
|
||||||
case '[': /* 3.3.2.1 */
|
case '[': /* 3.3.2.1 */
|
||||||
/* indexing follows the commutative laws */
|
/* indexing follows the commutative laws */
|
||||||
switch ((*expp)->ex_type->tp_fund) {
|
switch (expp_tp->tp_fund) {
|
||||||
case POINTER:
|
case POINTER:
|
||||||
case ARRAY:
|
case ARRAY:
|
||||||
break;
|
break;
|
||||||
|
@ -57,7 +59,7 @@ ch3bin(expp, oper, expr)
|
||||||
default:
|
default:
|
||||||
expr_error(*expp,
|
expr_error(*expp,
|
||||||
"indexing an object of type %s",
|
"indexing an object of type %s",
|
||||||
symbol2str((*expp)->ex_type->tp_fund));
|
symbol2str(expp_tp->tp_fund));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -67,27 +69,28 @@ ch3bin(expp, oper, expr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '(': /* 3.3.2.2 */
|
case '(': /* 3.3.2.2 */
|
||||||
if ( (*expp)->ex_type->tp_fund == POINTER &&
|
if ( expp_tp->tp_fund == POINTER &&
|
||||||
(*expp)->ex_type->tp_up->tp_fund == FUNCTION
|
expp_tp->tp_up->tp_fund == FUNCTION
|
||||||
) {
|
) {
|
||||||
ch3mon('*', expp);
|
ch3mon('*', expp);
|
||||||
|
expp_tp = (*expp)->ex_type;
|
||||||
}
|
}
|
||||||
if ((*expp)->ex_type->tp_fund != FUNCTION) {
|
if (expp_tp->tp_fund != FUNCTION) {
|
||||||
expr_error(*expp, "call of non-function (%s)",
|
expr_error(*expp, "call of non-function (%s)",
|
||||||
symbol2str((*expp)->ex_type->tp_fund));
|
symbol2str(expp_tp->tp_fund));
|
||||||
/* leave the expression; it may still serve */
|
/* leave the expression; it may still serve */
|
||||||
free_expression(expr); /* there go the parameters */
|
free_expression(expr); /* there go the parameters */
|
||||||
*expp = new_oper(error_type,
|
*expp = new_oper(error_type,
|
||||||
*expp, '(', (struct expr *)0);
|
*expp, '(', (struct expr *)0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*expp = new_oper((*expp)->ex_type->tp_up,
|
*expp = new_oper(expp_tp->tp_up,
|
||||||
*expp, '(', expr);
|
*expp, '(', expr);
|
||||||
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
(*expp)->ex_flags |= EX_SIDEEFFECTS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PARCOMMA: /* 3.3.2.2 */
|
case PARCOMMA: /* 3.3.2.2 */
|
||||||
if ((*expp)->ex_type->tp_fund == FUNCTION)
|
if (expp_tp->tp_fund == FUNCTION)
|
||||||
function2pointer(*expp);
|
function2pointer(*expp);
|
||||||
*expp = new_oper(expr->ex_type, *expp, PARCOMMA, expr);
|
*expp = new_oper(expr->ex_type, *expp, PARCOMMA, expr);
|
||||||
break;
|
break;
|
||||||
|
@ -128,7 +131,7 @@ ch3bin(expp, oper, expr)
|
||||||
case PLUSAB:
|
case PLUSAB:
|
||||||
case POSTINCR:
|
case POSTINCR:
|
||||||
case PLUSPLUS:
|
case PLUSPLUS:
|
||||||
if ((*expp)->ex_type->tp_fund == POINTER) {
|
if (expp_tp->tp_fund == POINTER) {
|
||||||
pointer_arithmetic(expp, oper, &expr);
|
pointer_arithmetic(expp, oper, &expr);
|
||||||
if (expr->ex_type->tp_size != (*expp)->ex_type->tp_size)
|
if (expr->ex_type->tp_size != (*expp)->ex_type->tp_size)
|
||||||
ch3cast(&expr, CAST, (*expp)->ex_type);
|
ch3cast(&expr, CAST, (*expp)->ex_type);
|
||||||
|
@ -147,7 +150,7 @@ ch3bin(expp, oper, expr)
|
||||||
case MINAB:
|
case MINAB:
|
||||||
case POSTDECR:
|
case POSTDECR:
|
||||||
case MINMIN:
|
case MINMIN:
|
||||||
if ((*expp)->ex_type->tp_fund == POINTER) {
|
if (expp_tp->tp_fund == POINTER) {
|
||||||
if (expr->ex_type->tp_fund == POINTER)
|
if (expr->ex_type->tp_fund == POINTER)
|
||||||
pntminuspnt(expp, oper, expr);
|
pntminuspnt(expp, oper, expr);
|
||||||
else {
|
else {
|
||||||
|
@ -230,10 +233,10 @@ ch3bin(expp, oper, expr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
if ( is_struct_or_union((*expp)->ex_type->tp_fund)
|
if ( is_struct_or_union(expp_tp->tp_fund)
|
||||||
|| is_struct_or_union(expr->ex_type->tp_fund)
|
|| is_struct_or_union(expr->ex_type->tp_fund)
|
||||||
) {
|
) {
|
||||||
if (!equal_type((*expp)->ex_type, expr->ex_type, 0))
|
if (!equal_type(expp_tp, expr->ex_type, 0))
|
||||||
expr_error(*expp, "illegal balance");
|
expr_error(*expp, "illegal balance");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -46,6 +46,9 @@ cstbin(expp, oper, expr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (uns) {
|
if (uns) {
|
||||||
|
#ifdef UNSIGNED_ARITH
|
||||||
|
o1 /= (UNSIGNED_ARITH) o2;
|
||||||
|
#else
|
||||||
/* this is more of a problem than you might
|
/* this is more of a problem than you might
|
||||||
think on C compilers which do not have
|
think on C compilers which do not have
|
||||||
unsigned arith (== long (probably)).
|
unsigned arith (== long (probably)).
|
||||||
|
@ -73,6 +76,7 @@ cstbin(expp, oper, expr)
|
||||||
rem >= o2 for o2 <= max_arith
|
rem >= o2 for o2 <= max_arith
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
o1 /= o2;
|
o1 /= o2;
|
||||||
|
@ -86,6 +90,9 @@ cstbin(expp, oper, expr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (uns) {
|
if (uns) {
|
||||||
|
#ifdef UNSIGNED_ARITH
|
||||||
|
o1 %= (UNSIGNED_ARITH) o2;
|
||||||
|
#else
|
||||||
if (o2 & arith_sign) {/* o2 > max_arith */
|
if (o2 & arith_sign) {/* o2 > max_arith */
|
||||||
o1 = (o1 >= 0 || o1 < o2) ? o1 : o1 - o2;
|
o1 = (o1 >= 0 || o1 < o2) ? o1 : o1 - o2;
|
||||||
/* this is the unsigned test
|
/* this is the unsigned test
|
||||||
|
@ -105,6 +112,7 @@ cstbin(expp, oper, expr)
|
||||||
rem = 2 * hrem + bit;
|
rem = 2 * hrem + bit;
|
||||||
o1 = (rem < 0 || rem >= o2) ? rem - o2 : rem;
|
o1 = (rem < 0 || rem >= o2) ? rem - o2 : rem;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
o1 %= o2;
|
o1 %= o2;
|
||||||
|
@ -122,12 +130,10 @@ cstbin(expp, oper, expr)
|
||||||
if (o2 == 0)
|
if (o2 == 0)
|
||||||
break;
|
break;
|
||||||
if (uns) {
|
if (uns) {
|
||||||
o1 >>= 1;
|
o1 = (o1 >> 1) & ~arith_sign;
|
||||||
o1 &= ~arith_sign;
|
o1 >>= (o2 - 1);
|
||||||
o1 >>= (o2-1);
|
|
||||||
}
|
}
|
||||||
else
|
else o1 >>= o2;
|
||||||
o1 >>= o2;
|
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
{
|
{
|
||||||
|
@ -139,10 +145,14 @@ cstbin(expp, oper, expr)
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case '>':
|
case '>':
|
||||||
if (uns) {
|
if (uns) {
|
||||||
|
#ifdef UNSIGNED_ARITH
|
||||||
|
o1 = (UNSIGNED_ARITH) o1 > (UNSIGNED_ARITH) o2;
|
||||||
|
#else
|
||||||
o1 = (o1 & arith_sign ?
|
o1 = (o1 & arith_sign ?
|
||||||
(o2 & arith_sign ? o1 > o2 : 1) :
|
(o2 & arith_sign ? o1 > o2 : 1) :
|
||||||
(o2 & arith_sign ? 0 : o1 > o2)
|
(o2 & arith_sign ? 0 : o1 > o2)
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
o1 = o1 > o2;
|
o1 = o1 > o2;
|
||||||
|
@ -157,10 +167,14 @@ cstbin(expp, oper, expr)
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case GREATEREQ:
|
case GREATEREQ:
|
||||||
if (uns) {
|
if (uns) {
|
||||||
|
#ifdef UNSIGNED_ARITH
|
||||||
|
o1 = (UNSIGNED_ARITH) o1 >= (UNSIGNED_ARITH) o2;
|
||||||
|
#else
|
||||||
o1 = (o1 & arith_sign ?
|
o1 = (o1 & arith_sign ?
|
||||||
(o2 & arith_sign ? o1 >= o2 : 1) :
|
(o2 & arith_sign ? o1 >= o2 : 1) :
|
||||||
(o2 & arith_sign ? 0 : o1 >= o2)
|
(o2 & arith_sign ? 0 : o1 >= o2)
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
o1 = o1 >= o2;
|
o1 = o1 >= o2;
|
||||||
|
@ -219,8 +233,7 @@ cut_size(expr)
|
||||||
if (remainder != 0 && remainder != ~full_mask[size])
|
if (remainder != 0 && remainder != ~full_mask[size])
|
||||||
if (!ResultKnown)
|
if (!ResultKnown)
|
||||||
expr_warning(expr,"overflow in constant expression");
|
expr_warning(expr,"overflow in constant expression");
|
||||||
o1 <<= nbits; /* ??? */
|
o1 = (o1 << nbits) >> nbits; /* ??? */
|
||||||
o1 >>= nbits;
|
|
||||||
}
|
}
|
||||||
expr->VL_VALUE = o1;
|
expr->VL_VALUE = o1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,7 +592,7 @@ get_text(formals, length)
|
||||||
do {
|
do {
|
||||||
/* being careful, as ever */
|
/* being careful, as ever */
|
||||||
if (pos+3 >= text_size)
|
if (pos+3 >= text_size)
|
||||||
text = Srealloc(text,
|
text = Realloc(text,
|
||||||
(unsigned) (text_size += RTEXTSIZE));
|
(unsigned) (text_size += RTEXTSIZE));
|
||||||
text[pos++] = c;
|
text[pos++] = c;
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
|
@ -606,7 +606,7 @@ get_text(formals, length)
|
||||||
if (c == '/') {
|
if (c == '/') {
|
||||||
c = GetChar();
|
c = GetChar();
|
||||||
if (pos+1 >= text_size)
|
if (pos+1 >= text_size)
|
||||||
text = Srealloc(text,
|
text = Realloc(text,
|
||||||
(unsigned) (text_size += RTEXTSIZE));
|
(unsigned) (text_size += RTEXTSIZE));
|
||||||
if (c == '*') {
|
if (c == '*') {
|
||||||
skipcomment();
|
skipcomment();
|
||||||
|
@ -633,7 +633,7 @@ get_text(formals, length)
|
||||||
if (n = find_name(id_buf, formals)) {
|
if (n = find_name(id_buf, formals)) {
|
||||||
/* construct the formal parameter mark */
|
/* construct the formal parameter mark */
|
||||||
if (pos+1 >= text_size)
|
if (pos+1 >= text_size)
|
||||||
text = Srealloc(text,
|
text = Realloc(text,
|
||||||
(unsigned) (text_size += RTEXTSIZE));
|
(unsigned) (text_size += RTEXTSIZE));
|
||||||
text[pos++] = FORMALP | (char) n;
|
text[pos++] = FORMALP | (char) n;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ get_text(formals, length)
|
||||||
register char *ptr = &id_buf[0];
|
register char *ptr = &id_buf[0];
|
||||||
|
|
||||||
while (pos + id_size >= text_size)
|
while (pos + id_size >= text_size)
|
||||||
text = Srealloc(text,
|
text = Realloc(text,
|
||||||
(unsigned) (text_size += RTEXTSIZE));
|
(unsigned) (text_size += RTEXTSIZE));
|
||||||
while (text[pos++] = *ptr++)
|
while (text[pos++] = *ptr++)
|
||||||
/* EMPTY */ ;
|
/* EMPTY */ ;
|
||||||
|
@ -650,7 +650,7 @@ get_text(formals, length)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pos+1 >= text_size)
|
if (pos+1 >= text_size)
|
||||||
text = Srealloc(text,
|
text = Realloc(text,
|
||||||
(unsigned) (text_size += RTEXTSIZE));
|
(unsigned) (text_size += RTEXTSIZE));
|
||||||
text[pos++] = c;
|
text[pos++] = c;
|
||||||
c = GetChar();
|
c = GetChar();
|
||||||
|
@ -697,7 +697,7 @@ GetIdentifier(skiponerr)
|
||||||
int skiponerr; /* skip the rest of the line on error */
|
int skiponerr; /* skip the rest of the line on error */
|
||||||
{
|
{
|
||||||
/* returns a pointer to the descriptor of the identifier that is
|
/* returns a pointer to the descriptor of the identifier that is
|
||||||
read from the input stream. When the input doe not contain
|
read from the input stream. When the input does not contain
|
||||||
an identifier, the rest of the line is skipped when
|
an identifier, the rest of the line is skipped when
|
||||||
skiponerr is on, and a null-pointer is returned.
|
skiponerr is on, and a null-pointer is returned.
|
||||||
The substitution of macros is disabled.
|
The substitution of macros is disabled.
|
||||||
|
@ -720,26 +720,23 @@ domacro()
|
||||||
|
|
||||||
EoiForNewline = 1;
|
EoiForNewline = 1;
|
||||||
if ((tok = GetToken(&tk)) == IDENTIFIER) {
|
if ((tok = GetToken(&tk)) == IDENTIFIER) {
|
||||||
if (strcmp(tk.tk_idf->id_text, "line")
|
if (! strcmp(tk.tk_idf->id_text, "line")) {
|
||||||
&& strcmp(tk.tk_idf->id_text, "pragma")) {
|
tok = GetToken(&tk);
|
||||||
error("illegal # line");
|
if (tok == INTEGER) {
|
||||||
SkipToNewLine();
|
do_line((unsigned int) tk.tk_ival);
|
||||||
return;
|
EoiForNewline = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( !strcmp(tk.tk_idf->id_text, "pragma")) {
|
else if (! strcmp(tk.tk_idf->id_text, "pragma")) {
|
||||||
do_pragma();
|
do_pragma();
|
||||||
EoiForNewline = 0;
|
EoiForNewline = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tok = GetToken(&tk);
|
|
||||||
}
|
}
|
||||||
if (tok != INTEGER) {
|
error("illegal # line");
|
||||||
error("illegal # line");
|
|
||||||
SkipToNewLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
do_line((unsigned int) tk.tk_ival);
|
|
||||||
EoiForNewline = 0;
|
EoiForNewline = 0;
|
||||||
|
SkipToNewLine();
|
||||||
}
|
}
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ string(register struct expr **expp;)
|
||||||
*/
|
*/
|
||||||
if (dot.tk_fund != fund)
|
if (dot.tk_fund != fund)
|
||||||
warning("illegal pasting of string literals");
|
warning("illegal pasting of string literals");
|
||||||
str = Srealloc(str, (unsigned) (--len + dot.tk_len));
|
str = Realloc(str, (unsigned) (--len + dot.tk_len));
|
||||||
for (i = 0; i < dot.tk_len; i++)
|
for (i = 0; i < dot.tk_len; i++)
|
||||||
str[len++] = dot.tk_bts[i];
|
str[len++] = dot.tk_bts[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ fltcstbin(expp, oper, expr)
|
||||||
*/
|
*/
|
||||||
flt_arith o1, o2;
|
flt_arith o1, o2;
|
||||||
int compar = 0;
|
int compar = 0;
|
||||||
arith cmpval;
|
int cmpval;
|
||||||
|
|
||||||
o1 = (*expp)->FL_ARITH;
|
o1 = (*expp)->FL_ARITH;
|
||||||
o2 = expr->FL_ARITH;
|
o2 = expr->FL_ARITH;
|
||||||
|
@ -103,7 +103,7 @@ fltcstbin(expp, oper, expr)
|
||||||
if ((*expp)->FL_VALUE) free((*expp)->FL_VALUE);
|
if ((*expp)->FL_VALUE) free((*expp)->FL_VALUE);
|
||||||
(*expp)->FL_VALUE = 0;
|
(*expp)->FL_VALUE = 0;
|
||||||
if (compar) {
|
if (compar) {
|
||||||
fill_int_expr(*expp, cmpval, INT);
|
fill_int_expr(*expp, (arith)cmpval, INT);
|
||||||
} else {
|
} else {
|
||||||
(*expp)->FL_ARITH = o1;
|
(*expp)->FL_ARITH = o1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,12 +412,10 @@ global_redecl(idf, new_sc, tp)
|
||||||
in storage class.
|
in storage class.
|
||||||
*/
|
*/
|
||||||
register struct def *def = idf->id_def;
|
register struct def *def = idf->id_def;
|
||||||
int retval;
|
|
||||||
|
|
||||||
if (!(retval = equal_type(tp, def->df_type, 0)))
|
if (!equal_type(tp, def->df_type, 0))
|
||||||
error("redeclaration of %s with different type", idf->id_text);
|
error("redeclaration of %s with different type", idf->id_text);
|
||||||
else if (retval == 1)
|
else update_proto(tp, def->df_type);
|
||||||
update_proto(tp, def->df_type);
|
|
||||||
if (tp->tp_fund == ARRAY) {
|
if (tp->tp_fund == ARRAY) {
|
||||||
/* Multiple array declaration; this may be interesting */
|
/* Multiple array declaration; this may be interesting */
|
||||||
if (tp->tp_size < 0) { /* new decl has [] */
|
if (tp->tp_size < 0) { /* new decl has [] */
|
||||||
|
|
|
@ -34,8 +34,6 @@ struct mkey {
|
||||||
{0, K_UNKNOWN}
|
{0, K_UNKNOWN}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *strcpy();
|
|
||||||
|
|
||||||
init_pp()
|
init_pp()
|
||||||
{
|
{
|
||||||
static char *months[12] = {
|
static char *months[12] = {
|
||||||
|
|
|
@ -265,12 +265,6 @@ init()
|
||||||
pointer arithmetic type which is equal to either
|
pointer arithmetic type which is equal to either
|
||||||
int_type or long_type, depending on the pointer_size
|
int_type or long_type, depending on the pointer_size
|
||||||
*/
|
*/
|
||||||
if ((int)pointer_size == (int)word_size)
|
|
||||||
pa_type = word_type;
|
|
||||||
else
|
|
||||||
if ((int)pointer_size == (int)short_size)
|
|
||||||
pa_type = short_type;
|
|
||||||
else
|
|
||||||
if ((int)pointer_size == (int)int_size)
|
if ((int)pointer_size == (int)int_size)
|
||||||
pa_type = int_type;
|
pa_type = int_type;
|
||||||
else
|
else
|
||||||
|
@ -283,6 +277,8 @@ init()
|
||||||
fatal("int_size and word_size are not equal");
|
fatal("int_size and word_size are not equal");
|
||||||
if ((int)short_size > (int)int_size || (int)int_size > (int)long_size)
|
if ((int)short_size > (int)int_size || (int)int_size > (int)long_size)
|
||||||
fatal("sizes of short/int/long decreasing");
|
fatal("sizes of short/int/long decreasing");
|
||||||
|
if ((int)float_size > (int)double_size || (int)double_size > (int)lngdbl_size)
|
||||||
|
fatal("sizes of float/double/long double decreasing");
|
||||||
|
|
||||||
/* Build a type for function returning int (3.3.2.2) */
|
/* Build a type for function returning int (3.3.2.2) */
|
||||||
funint_type = construct_type(FUNCTION, int_type, 0, (arith)0, NO_PROTO);
|
funint_type = construct_type(FUNCTION, int_type, 0, (arith)0, NO_PROTO);
|
||||||
|
|
|
@ -62,8 +62,8 @@ add_proto(pl, ds, dc, level)
|
||||||
later on it's decided whether they were prototypes
|
later on it's decided whether they were prototypes
|
||||||
or actual declarations.
|
or actual declarations.
|
||||||
*/
|
*/
|
||||||
register struct idf *idf;
|
register struct idf *idf = dc->dc_idf;
|
||||||
register struct def *def = (struct def *)0;
|
register struct def *def = idf ? idf->id_def : (struct def *)0;
|
||||||
register int sc = ds->ds_sc;
|
register int sc = ds->ds_sc;
|
||||||
register struct type *type;
|
register struct type *type;
|
||||||
char formal_array = 0;
|
char formal_array = 0;
|
||||||
|
@ -71,8 +71,6 @@ add_proto(pl, ds, dc, level)
|
||||||
ASSERT(ds->ds_type != (struct type *)0);
|
ASSERT(ds->ds_type != (struct type *)0);
|
||||||
|
|
||||||
pl->pl_flag = PL_FORMAL;
|
pl->pl_flag = PL_FORMAL;
|
||||||
if ((idf = dc->dc_idf) != (struct idf *)0)
|
|
||||||
def = idf->id_def;
|
|
||||||
type = declare_type(ds->ds_type, dc);
|
type = declare_type(ds->ds_type, dc);
|
||||||
if (type->tp_size < (arith)0 && actual_declaration(sc, type)) {
|
if (type->tp_size < (arith)0 && actual_declaration(sc, type)) {
|
||||||
extern char *symbol2str();
|
extern char *symbol2str();
|
||||||
|
@ -159,7 +157,7 @@ gettag(tp, idpp)
|
||||||
struct type *tp;
|
struct type *tp;
|
||||||
struct idf **idpp;
|
struct idf **idpp;
|
||||||
{
|
{
|
||||||
struct tag *tg;
|
struct tag *tg = (struct tag *)0;
|
||||||
|
|
||||||
while (tp->tp_up) tp = tp->tp_up;
|
while (tp->tp_up) tp = tp->tp_up;
|
||||||
*idpp = tp->tp_idf;
|
*idpp = tp->tp_idf;
|
||||||
|
@ -167,7 +165,6 @@ struct idf **idpp;
|
||||||
case ENUM: tg = tp->tp_idf->id_enum; break;
|
case ENUM: tg = tp->tp_idf->id_enum; break;
|
||||||
case UNION:
|
case UNION:
|
||||||
case STRUCT: tg = tp->tp_idf->id_struct; break;
|
case STRUCT: tg = tp->tp_idf->id_struct; break;
|
||||||
default: return (struct tag *)0;
|
|
||||||
}
|
}
|
||||||
return tg;
|
return tg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue