forked from Mirrors/tinycc
tccpp: no cache for include if #elif seen
#ifndef guards are cached, however after #elif on the same level, the file must be re-read. Also: preprocess asm as such even when there is no assembler (arm).master
parent
5805b07218
commit
1c4cf18556
2
libtcc.c
2
libtcc.c
|
@ -1334,13 +1334,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
|
||||||
tcc_strdup(filename));
|
tcc_strdup(filename));
|
||||||
|
|
||||||
parse_flags = 0;
|
parse_flags = 0;
|
||||||
#ifdef CONFIG_TCC_ASM
|
|
||||||
/* if .S file, define __ASSEMBLER__ like gcc does */
|
/* if .S file, define __ASSEMBLER__ like gcc does */
|
||||||
if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {
|
if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {
|
||||||
tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
|
tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
|
||||||
parse_flags = PARSE_FLAG_ASM_FILE;
|
parse_flags = PARSE_FLAG_ASM_FILE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (flags & AFF_PREPROCESS) {
|
if (flags & AFF_PREPROCESS) {
|
||||||
ret = tcc_preprocess(s1);
|
ret = tcc_preprocess(s1);
|
||||||
|
|
17
tccpp.c
17
tccpp.c
|
@ -1773,7 +1773,7 @@ ST_FUNC void preprocess(int is_bof)
|
||||||
buf1[0] = 0;
|
buf1[0] = 0;
|
||||||
|
|
||||||
} else if (i == 1) {
|
} else if (i == 1) {
|
||||||
/* search in current dir if "header.h" */
|
/* search in file's dir if "header.h" */
|
||||||
if (c != '\"')
|
if (c != '\"')
|
||||||
continue;
|
continue;
|
||||||
path = file->filename;
|
path = file->filename;
|
||||||
|
@ -1860,16 +1860,17 @@ include_done:
|
||||||
if (c > 1)
|
if (c > 1)
|
||||||
tcc_error("#elif after #else");
|
tcc_error("#elif after #else");
|
||||||
/* last #if/#elif expression was true: we skip */
|
/* last #if/#elif expression was true: we skip */
|
||||||
if (c == 1)
|
if (c == 1) {
|
||||||
goto skip;
|
c = 0;
|
||||||
c = expr_preprocess();
|
} else {
|
||||||
s1->ifdef_stack_ptr[-1] = c;
|
c = expr_preprocess();
|
||||||
|
s1->ifdef_stack_ptr[-1] = c;
|
||||||
|
}
|
||||||
test_else:
|
test_else:
|
||||||
if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
|
if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
|
||||||
file->ifndef_macro = 0;
|
file->ifndef_macro = 0;
|
||||||
test_skip:
|
test_skip:
|
||||||
if (!(c & 1)) {
|
if (!(c & 1)) {
|
||||||
skip:
|
|
||||||
preprocess_skip();
|
preprocess_skip();
|
||||||
is_bof = 0;
|
is_bof = 0;
|
||||||
goto redo;
|
goto redo;
|
||||||
|
@ -1899,10 +1900,10 @@ include_done:
|
||||||
case TOK_LINE:
|
case TOK_LINE:
|
||||||
next();
|
next();
|
||||||
if (tok != TOK_CINT)
|
if (tok != TOK_CINT)
|
||||||
_line_err:
|
_line_err:
|
||||||
tcc_error("wrong #line format");
|
tcc_error("wrong #line format");
|
||||||
n = tokc.i;
|
n = tokc.i;
|
||||||
_line_num:
|
_line_num:
|
||||||
next();
|
next();
|
||||||
if (tok != TOK_LINEFEED) {
|
if (tok != TOK_LINEFEED) {
|
||||||
if (tok == TOK_STR)
|
if (tok == TOK_STR)
|
||||||
|
|
Loading…
Reference in New Issue