History

comment parsing fix - bitfields partial fix

bellard committed 22 years ago

Commit 22d8df91 parent 8da2d681 file · +20 −7Browse files

Unified · Split

tcc.c+20−7
@@ -1823,19 +1823,27 @@ static uint8_t *parse_line_comment(uint8_t *p) · 1822 unmodified lines
18231823 p++;
18241824 for(;;) {
18251825 c = *p;
1826+ redo:
18261827 if (c == '\n' || c == CH_EOF) {
18271828 break;
18281829 } else if (c == '\\') {
1829− PEEKC_EOB(c, p);
1830− if (c == '\n') {
1831− file->line_num++;
1832− PEEKC_EOB(c, p);
1833− } else if (c == '\r') {
1830+ file->buf_ptr = p;
1831+ c = handle_eob();
1832+ p = file->buf_ptr;
1833+ if (c == '\\') {
18341834 PEEKC_EOB(c, p);
18351835 if (c == '\n') {
18361836 file->line_num++;
18371837 PEEKC_EOB(c, p);
1838+ } else if (c == '\r') {
1839+ PEEKC_EOB(c, p);
1840+ if (c == '\n') {
1841+ file->line_num++;
1842+ PEEKC_EOB(c, p);
1843+ }
18381844 }
1845+ } else {
1846+ goto redo;
18391847 }
18401848 } else {
18411849 p++;
@@ -5430,7 +5438,7 @@ void force_charshort_cast(int t) · 3588 unmodified lines
54305438 }
54315439 }
54325440
5433−/* cast 'vtop' to 'type' */
5441+/* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
54345442 static void gen_cast(CType *type)
54355443 {
54365444 int sbt, dbt, sf, df, c;
@@ -5442,7 +5450,12 @@ static void gen_cast(CType *type) · 5 unmodified lines
54425450 vtop->r &= ~VT_MUSTCAST;
54435451 force_charshort_cast(vtop->type.t);
54445452 }
5445−
5453+
5454+ /* bitfields first get cast to ints */
5455+ if (vtop->type.t & VT_BITFIELD) {
5456+ gv(RC_INT);
5457+ }
5458+
54465459 dbt = type->t & (VT_BTYPE | VT_UNSIGNED);
54475460 sbt = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
54485461

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t