A preprocessor should Interpret an input line "# NUM FILENAME" as "#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
This commit is contained in:
7
tccpp.c
7
tccpp.c
@ -1626,7 +1626,12 @@ include_done:
|
|||||||
case TOK_LINE:
|
case TOK_LINE:
|
||||||
next();
|
next();
|
||||||
if (tok != TOK_CINT)
|
if (tok != TOK_CINT)
|
||||||
tcc_error("#line");
|
tcc_error("A #line format is wrong");
|
||||||
|
case TOK_PPNUM:
|
||||||
|
if (tok != TOK_CINT) {
|
||||||
|
char *p = tokc.cstr->data;
|
||||||
|
tokc.i = strtoul(p, (char **)&p, 10);
|
||||||
|
}
|
||||||
file->line_num = tokc.i - 1; /* the line number will be incremented after */
|
file->line_num = tokc.i - 1; /* the line number will be incremented after */
|
||||||
next();
|
next();
|
||||||
if (tok != TOK_LINEFEED) {
|
if (tok != TOK_LINEFEED) {
|
||||||
|
|||||||
Reference in New Issue
Block a user