Le samedi 27 décembre 2014, 15:29:53 Sergey Korshunoff a écrit :
> A preprocessor should Interpret an input line
>         # NUM "FILENAME"
> like
>         #line NUM "FILENAME"
> 
> A cpp from gcc do this.  A test case:
>          tcc -E tccasm.c -o tccasm.i
>          tcc -E tccasm.i -o tccasm.ii
> 
> After a patch the line numbers in tccasm.ii are the same  as in tccasm.i

@@ -1624,7 +1627,11 @@
         }
         break;
     case TOK_LINE:
-        next();
+    case TOK_PPNUM:
+       if (tok == TOK_LINE)
+           next();
+       else
+           parse_number((char *)tokc.cstr->data);
         if (tok != TOK_CINT)
             tcc_error("#line");
         file->line_num = tokc.i - 1; /* the line number will be incremented 
after */

There is already all the logic to parse the line number after the next 
(obviously since otherwise TOK_LINE parsing would not be working). So I don't 
think there is any else statement needed. If you think parse_number is more 
appropriate than the current adhoc parsing please justify *and* use it for 
both cases.

Best regards,

Thomas

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to