aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-27 15:25:49 +0300
committerseyko <seyko2@gmail.com>2015-04-27 15:25:49 +0300
commit2df290073b04de51b699e58dde943afaeb0757dc (patch)
tree6cc96c9de536eb188d4d0a561e9b2531b45b4e1f
parent2d3458363e4e529d80030a648a806fef0c13cf71 (diff)
downloadtinycc-2df290073b04de51b699e58dde943afaeb0757dc.tar.gz
tinycc-2df290073b04de51b699e58dde943afaeb0757dc.tar.bz2
preprocess: "assign PARSE_FLAG_ASM_COMMENTS only for asm files"
resolve a problem with the following test.c program, tcc -E test.c #ifdef _XOPEN_SOURCE # define __USE_XOPEN 1 # if (_XOPEN_SOURCE - 0) >= 500 # define __USE_XOPEN_EXTENDED 1 # define __USE_UNIX98 1 # undef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # if (_XOPEN_SOURCE - 0) >= 600 # define __USE_XOPEN2K 1 # undef __USE_ISOC99 # define __USE_ISOC99 1 # endif # else # ifdef _XOPEN_SOURCE_EXTENDED # define __USE_XOPEN_EXTENDED 1 # endif # endif #endif int main() {} // # 17 "aaa.c" // aaa.c:17: error: #endif without matching #if
-rw-r--r--libtcc.c2
-rw-r--r--tccpp.c5
2 files changed, 3 insertions, 4 deletions
diff --git a/libtcc.c b/libtcc.c
index 90dd185..abef9c8 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1166,7 +1166,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags,
/* if .S file, define __ASSEMBLER__ like gcc does */
if ((filetype == TCC_FILETYPE_ASM) || (filetype == TCC_FILETYPE_ASM_PP)) {
tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
- parse_flags = PARSE_FLAG_ASM_FILE;
+ parse_flags = PARSE_FLAG_ASM_FILE | PARSE_FLAG_ASM_COMMENTS;
}
#endif
diff --git a/tccpp.c b/tccpp.c
index 05e7c1f..de3f8ae 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -3290,9 +3290,8 @@ ST_FUNC int tcc_preprocess(TCCState *s1)
preprocess_init(s1);
ch = file->buf_ptr[0];
tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
- parse_flags = (parse_flags & PARSE_FLAG_ASM_FILE);
- parse_flags |= PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_PREPROCESS |
- PARSE_FLAG_LINEFEED | PARSE_FLAG_SPACES;
+ parse_flags &= (PARSE_FLAG_ASM_FILE | PARSE_FLAG_ASM_COMMENTS);
+ parse_flags |= PARSE_FLAG_PREPROCESS | PARSE_FLAG_LINEFEED | PARSE_FLAG_SPACES;
token_seen = 0;
file->line_ref = 0;
file_ref = NULL;