v2 of the patch, which uses strtoul() insteed of the parse_number()
2015-01-04 10:55 GMT+03:00, Sergey Korshunoff <[email protected]>: > But after testing: if "else" removed then tcc can not handle a #line > directive.And with first patch tcc process rigth all forms: > # line XXX "file_name" > # XXX "file_name" > > 2015-01-04 10:43 GMT+03:00, Sergey Korshunoff <[email protected]>: >> Yes, It looks like else is not needed when processing >> # line XXX "filename" >> We must only get a next token and parse it as number. >> >> 2015-01-04 0:36 GMT+03:00, Thomas Preudomme <[email protected]>: >>> 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 >>> >> >
2014-12-27-01-pp-num-as-line-1.patch
Description: Binary data
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
