tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH] pp should interpret #num as #line num


From: Sergey Korshunoff
Subject: Re: [Tinycc-devel] [PATCH] pp should interpret #num as #line num
Date: Sun, 4 Jan 2015 10:43:31 +0300

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 <address@hidden>:
> 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
>

Attachment: 2014-12-27-01-pp-num-as-line-2.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]