comment parsing fix - bitfields partial fix

This commit is contained in:
bellard 2004-10-02 13:48:50 +00:00
parent 8da2d689df
commit 22d8df96c6

27
tcc.c
View file

@ -1823,19 +1823,27 @@ static uint8_t *parse_line_comment(uint8_t *p)
p++; p++;
for(;;) { for(;;) {
c = *p; c = *p;
redo:
if (c == '\n' || c == CH_EOF) { if (c == '\n' || c == CH_EOF) {
break; break;
} else if (c == '\\') { } else if (c == '\\') {
PEEKC_EOB(c, p); file->buf_ptr = p;
if (c == '\n') { c = handle_eob();
file->line_num++; p = file->buf_ptr;
PEEKC_EOB(c, p); if (c == '\\') {
} else if (c == '\r') {
PEEKC_EOB(c, p); PEEKC_EOB(c, p);
if (c == '\n') { if (c == '\n') {
file->line_num++; file->line_num++;
PEEKC_EOB(c, p); PEEKC_EOB(c, p);
} else if (c == '\r') {
PEEKC_EOB(c, p);
if (c == '\n') {
file->line_num++;
PEEKC_EOB(c, p);
}
} }
} else {
goto redo;
} }
} else { } else {
p++; p++;
@ -5430,7 +5438,7 @@ void force_charshort_cast(int t)
} }
} }
/* cast 'vtop' to 'type' */ /* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
static void gen_cast(CType *type) static void gen_cast(CType *type)
{ {
int sbt, dbt, sf, df, c; int sbt, dbt, sf, df, c;
@ -5442,7 +5450,12 @@ static void gen_cast(CType *type)
vtop->r &= ~VT_MUSTCAST; vtop->r &= ~VT_MUSTCAST;
force_charshort_cast(vtop->type.t); force_charshort_cast(vtop->type.t);
} }
/* bitfields first get cast to ints */
if (vtop->type.t & VT_BITFIELD) {
gv(RC_INT);
}
dbt = type->t & (VT_BTYPE | VT_UNSIGNED); dbt = type->t & (VT_BTYPE | VT_UNSIGNED);
sbt = vtop->type.t & (VT_BTYPE | VT_UNSIGNED); sbt = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);