aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-03-03 14:06:05 +0300
committerseyko <seyko2@gmail.com>2015-03-03 14:06:05 +0300
commit5e3e32147473504c01125cea16f8d047c8e63766 (patch)
tree48233fd4c40ad1cda48567e02ae68d720e538d6d
parent1706d2254b168309b2c38985750b6d00ad254ef3 (diff)
downloadtinycc-5e3e32147473504c01125cea16f8d047c8e63766.tar.gz
tinycc-5e3e32147473504c01125cea16f8d047c8e63766.tar.bz2
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
-rw-r--r--tccpp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tccpp.c b/tccpp.c
index 42f34aa..405a5d6 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1626,7 +1626,12 @@ include_done:
case TOK_LINE:
next();
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 */
next();
if (tok != TOK_LINEFEED) {