improved volatiles, added warning for possibly nested comments
This commit is contained in:
parent
2782412b59
commit
84b8c8a6ca
|
@ -449,7 +449,7 @@ skipcomment()
|
|||
EOI is returned by LoadChar only on encountering EOF of the
|
||||
top-level file...
|
||||
*/
|
||||
register int c;
|
||||
register int c, oldc = '\0';
|
||||
|
||||
NoUnstack++;
|
||||
c = GetChar();
|
||||
|
@ -468,12 +468,16 @@ skipcomment()
|
|||
#endif LINT
|
||||
return;
|
||||
}
|
||||
oldc = c;
|
||||
c = GetChar();
|
||||
#ifdef LINT
|
||||
lint_comment_char(c);
|
||||
#endif LINT
|
||||
} /* last Character seen was '*' */
|
||||
c = GetChar();
|
||||
if ( c != '/' && oldc == '/')
|
||||
lexwarning("comment inside comment ?");
|
||||
oldc = '*';
|
||||
#ifdef LINT
|
||||
lint_comment_char(c);
|
||||
#endif LINT
|
||||
|
|
|
@ -154,6 +154,9 @@ ch3sel(expp, oper, idf)
|
|||
if (oper == '.' && exp->ex_flags & EX_READONLY) {
|
||||
exp->ex_type = qualifier_type(exp->ex_type, TQ_CONST);
|
||||
}
|
||||
if (exp->ex_flags & EX_VOLATILE) {
|
||||
exp->ex_type = qualifier_type(exp->ex_type, TQ_VOLATILE);
|
||||
}
|
||||
*expp = exp;
|
||||
}
|
||||
|
||||
|
@ -558,18 +561,19 @@ equal_proto(pl, opl)
|
|||
return !(pl || opl);
|
||||
}
|
||||
|
||||
/* check if a type has a const declared member */
|
||||
recurconst(tp)
|
||||
/* check if a type has a consqualified member */
|
||||
recurqual(tp, qual)
|
||||
struct type *tp;
|
||||
int qual;
|
||||
{
|
||||
register struct sdef *sdf;
|
||||
|
||||
ASSERT(tp);
|
||||
|
||||
if (tp->tp_typequal & TQ_CONST) return 1;
|
||||
if (tp->tp_typequal & qual) return 1;
|
||||
sdf = tp->tp_sdef;
|
||||
while (sdf) {
|
||||
if (recurconst(sdf->sd_type))
|
||||
if (recurqual(sdf->sd_type, qual))
|
||||
return 1;
|
||||
sdf = sdf->sd_sdef;
|
||||
}
|
||||
|
@ -595,7 +599,6 @@ ch3asgn(expp, oper, expr)
|
|||
*/
|
||||
register struct expr *exp = *expp;
|
||||
int fund = exp->ex_type->tp_fund;
|
||||
int vol = 0;
|
||||
struct type *tp;
|
||||
char *oper_string = symbol2str(oper);
|
||||
|
||||
|
@ -608,17 +611,11 @@ ch3asgn(expp, oper, expr)
|
|||
} else if (exp->ex_flags & EX_READONLY) {
|
||||
expr_error(exp, "operand of %s is read-only", oper_string);
|
||||
} else if (fund == STRUCT || fund == UNION) {
|
||||
if (recurconst(exp->ex_type))
|
||||
if (recurqual(exp->ex_type, TQ_CONST))
|
||||
expr_error(expr,"operand of %s contains a const-qualified member",
|
||||
oper_string);
|
||||
}
|
||||
|
||||
/* Preserve volatile markers across the tree.
|
||||
This is questionable, depending on the way the optimizer
|
||||
wants this information.
|
||||
*/
|
||||
vol = (exp->ex_flags & EX_VOLATILE) || (expr->ex_flags & EX_VOLATILE);
|
||||
|
||||
if (oper == '=') {
|
||||
ch3cast(&expr, oper, exp->ex_type);
|
||||
tp = expr->ex_type;
|
||||
|
@ -654,7 +651,7 @@ ch3asgn(expp, oper, expr)
|
|||
exp = new_oper(exp->ex_type, exp, oper, expr);
|
||||
#endif NOBITFIELD
|
||||
exp->OP_TYPE = tp; /* for EVAL() */
|
||||
exp->ex_flags |= vol ? (EX_SIDEEFFECTS|EX_VOLATILE) : EX_SIDEEFFECTS;
|
||||
exp->ex_flags |= EX_SIDEEFFECTS;
|
||||
*expp = exp;
|
||||
}
|
||||
|
||||
|
|
|
@ -575,10 +575,6 @@ code_expr(expr, val, code, tlbl, flbl)
|
|||
if (! options['L']) /* profiling */
|
||||
C_lin((arith)(expr->ex_line));
|
||||
|
||||
/* HERE WE SHOULD GENERATE A MESSAGE:
|
||||
if (expr->ex_flags & EX_VOLATILE)
|
||||
HANDS_OFF
|
||||
*/
|
||||
EVAL(expr, val, code, tlbl, flbl);
|
||||
#else LINT
|
||||
lint_expr(expr, code ? USED : IGNORED);
|
||||
|
|
|
@ -70,9 +70,11 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
int val, code;
|
||||
label true_label, false_label;
|
||||
{
|
||||
register int gencode = (code == TRUE
|
||||
&& (expr->ex_type->tp_size > 0
|
||||
|| expr->ex_type->tp_fund == FUNCTION));
|
||||
int vol = (code != TRUE && recurqual(expr->ex_type, TQ_VOLATILE));
|
||||
register int gencode = ((code == TRUE
|
||||
&& (expr->ex_type->tp_size > 0
|
||||
|| expr->ex_type->tp_fund == FUNCTION))
|
||||
|| vol);
|
||||
|
||||
switch (expr->ex_class) {
|
||||
case Value: /* just a simple value */
|
||||
|
@ -661,7 +663,9 @@ EVAL(expr, val, code, true_label, false_label)
|
|||
default:
|
||||
crash("(EVAL) bad expression class");
|
||||
}
|
||||
if (expr->ex_flags & EX_VOLATILE) C_nop();
|
||||
if (expr->ex_flags & EX_VOLATILE || vol) C_nop();
|
||||
if (vol) C_asp(expr->ex_type->tp_size);
|
||||
|
||||
}
|
||||
|
||||
/* compare() serves as an auxiliary function of EVAL */
|
||||
|
|
Loading…
Reference in a new issue