changeset 300:66b75bc13651

[project @ 2004-10-02 13:48:50 by bellard] comment parsing fix - bitfields partial fix
author bellard
date Sat, 02 Oct 2004 13:48:50 +0000
parents f9b0dd21990c
children 59f71fb87bd3
files tcc.c
diffstat 1 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tcc.c	Sat Oct 02 13:46:33 2004 +0000
+++ b/tcc.c	Sat Oct 02 13:48:50 2004 +0000
@@ -1823,19 +1823,27 @@
     p++;
     for(;;) {
         c = *p;
+    redo:
         if (c == '\n' || c == CH_EOF) {
             break;
         } else if (c == '\\') {
-            PEEKC_EOB(c, p);
-            if (c == '\n') {
-                file->line_num++;
-                PEEKC_EOB(c, p);
-            } else if (c == '\r') {
+            file->buf_ptr = p;
+            c = handle_eob();
+            p = file->buf_ptr;
+            if (c == '\\') {
                 PEEKC_EOB(c, p);
                 if (c == '\n') {
                     file->line_num++;
                     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 {
             p++;
@@ -5430,7 +5438,7 @@
     }
 }
 
-/* cast 'vtop' to 'type' */
+/* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
 static void gen_cast(CType *type)
 {
     int sbt, dbt, sf, df, c;
@@ -5442,7 +5450,12 @@
         vtop->r &= ~VT_MUSTCAST;
         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);
     sbt = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);