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
grischka 2016-10-04 17:31:40 +02:00
parent 5805b07218
commit 1c4cf18556
2 changed files with 9 additions and 10 deletions

View File

@ -1334,13 +1334,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
tcc_strdup(filename));
parse_flags = 0;
#ifdef CONFIG_TCC_ASM
/* if .S file, define __ASSEMBLER__ like gcc does */
if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) {
tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
parse_flags = PARSE_FLAG_ASM_FILE;
}
#endif
if (flags & AFF_PREPROCESS) {
ret = tcc_preprocess(s1);

17
tccpp.c
View File

@ -1773,7 +1773,7 @@ ST_FUNC void preprocess(int is_bof)
buf1[0] = 0;
} else if (i == 1) {
/* search in current dir if "header.h" */
/* search in file's dir if "header.h" */
if (c != '\"')
continue;
path = file->filename;
@ -1860,16 +1860,17 @@ include_done:
if (c > 1)
tcc_error("#elif after #else");
/* last #if/#elif expression was true: we skip */
if (c == 1)
goto skip;
c = expr_preprocess();
s1->ifdef_stack_ptr[-1] = c;
if (c == 1) {
c = 0;
} else {
c = expr_preprocess();
s1->ifdef_stack_ptr[-1] = c;
}
test_else:
if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
file->ifndef_macro = 0;
test_skip:
if (!(c & 1)) {
skip:
preprocess_skip();
is_bof = 0;
goto redo;
@ -1899,10 +1900,10 @@ include_done:
case TOK_LINE:
next();
if (tok != TOK_CINT)
_line_err:
_line_err:
tcc_error("wrong #line format");
n = tokc.i;
_line_num:
_line_num:
next();
if (tok != TOK_LINEFEED) {
if (tok == TOK_STR)