improved type-checking, fixed preprocessor bug, fixed syntax bug

This commit is contained in:
eck 1989-11-27 11:37:11 +00:00
parent 5d81b090b9
commit 671556cfc4
5 changed files with 27 additions and 14 deletions

View file

@ -170,7 +170,7 @@ ch3cast(expp, oper, tp)
expression of class Type.
*/
register struct type *oldtp;
int qual_lev;
int qual_lev, ascompat = 0;
if (oper == RETURN && tp->tp_fund == VOID) {
expr_strict(*expp, "return <expression> in function returning void");
@ -196,14 +196,28 @@ ch3cast(expp, oper, tp)
return;
}
#endif NOBITFIELD
if (oper == CASTAB || oper == '=' || oper == RETURN) {
qual_lev = -2;
} else if (oper == CAST) qual_lev = -999; /* ??? hack */
else qual_lev = -1;
switch (oper) {
default: qual_lev = -1; break;
case CAST: qual_lev = -999; break; /* ??? hack */
case CASTAB:
case '=':
case RETURN: ascompat = 1; /* assignment compatibility */
/* fallthrough */
case '-':
case '<':
case '>':
case LESSEQ:
case GREATEREQ:
case EQUAL:
case NOTEQUAL:
case ':':
qual_lev = -2;
break;
}
if (equal_type(tp, oldtp, qual_lev)) {
/* life is easy */
if (qual_lev == -2 && tp->tp_fund == POINTER) {
if (ascompat && tp->tp_fund == POINTER) {
if ((tp->tp_up->tp_typequal & oldtp->tp_up->tp_typequal)
!= oldtp->tp_up->tp_typequal) {
expr_strict( *expp, "qualifier error");
@ -377,13 +391,10 @@ equal_type(tp, otp, qual_lev)
if (!tp
|| !otp
|| (tp->tp_fund != otp->tp_fund)
|| (tp->tp_size != otp->tp_size)
|| (tp->tp_unsigned != otp->tp_unsigned)
|| (tp->tp_align != otp->tp_align))
return 0;
if (tp->tp_fund != ARRAY) {
if (tp->tp_size != otp->tp_size)
return 0;
}
if (qual_lev >= 0) {
if (tp->tp_typequal != otp->tp_typequal)
strict("illegal qualifiers");

View file

@ -28,7 +28,8 @@ ch3mon(oper, expp)
*/
register struct expr *expr;
any2opnd(expp, oper);
if (oper != PLUSPLUS && oper != MINMIN)
any2opnd(expp, oper);
switch (oper) {
case '*': /* 3.3.3.2 */

View file

@ -604,6 +604,7 @@ get_text(formals, length)
c = GetChar();
repl->r_ptr = repl->r_text = Malloc(repl->r_size = ITEXTSIZE);
*repl->r_ptr = '\0';
while ((c != EOI) && (class(c) != STNL)) {
if (BLANK(c)) {
if (!blank++) add2repl(repl, ' ');

View file

@ -92,15 +92,14 @@ postfix_expression(register struct expr **expp;)
|
[ '.' | ARROW ] { oper = DOT; }
identifier(&idf) { ch3sel(expp, oper, idf); }
]*
[
|
[
PLUSPLUS { oper = POSTINCR; }
|
MINMIN { oper = POSTDECR; }
]
{ ch3incr(expp, oper); }
]?
]*
;
parameter_list(struct expr **expp;)

View file

@ -549,6 +549,7 @@ macro2buffer(repl, idf, args)
int err = 0;
char *stringify();
ASSERT(ptr[idf->id_macro->mc_length] == '\0');
while (*ptr) {
if (*ptr == '\'' || *ptr == '"') {
register int delim = *ptr;