#ifndef guards are cached, however after #elif on the same level, the file must be re-read.
Unified · Split
| @@ -1334,13 +1334,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1333 unmodified lines | ||
| 1334 | 1334 | tcc_strdup(filename)); |
| 1335 | 1335 | |
| 1336 | 1336 | parse_flags = 0; |
| 1337 | −#ifdef CONFIG_TCC_ASM | |
| 1338 | 1337 | /* if .S file, define __ASSEMBLER__ like gcc does */ |
| 1339 | 1338 | if (filetype == AFF_TYPE_ASM || filetype == AFF_TYPE_ASMPP) { |
| 1340 | 1339 | tcc_define_symbol(s1, "__ASSEMBLER__", NULL); |
| 1341 | 1340 | parse_flags = PARSE_FLAG_ASM_FILE; |
| 1342 | 1341 | } |
| 1343 | −#endif | |
| 1344 | 1342 | |
| 1345 | 1343 | if (flags & AFF_PREPROCESS) { |
| 1346 | 1344 | ret = tcc_preprocess(s1); |
| @@ -1773,7 +1773,7 @@ ST_FUNC void preprocess(int is_bof) · 1772 unmodified lines | ||
| 1773 | 1773 | buf1[0] = 0; |
| 1774 | 1774 | |
| 1775 | 1775 | } else if (i == 1) { |
| 1776 | − /* search in current dir if "header.h" */ | |
| 1776 | + /* search in file's dir if "header.h" */ | |
| 1777 | 1777 | if (c != '\"') |
| 1778 | 1778 | continue; |
| 1779 | 1779 | path = file->filename; |
| @@ -1860,16 +1860,17 @@ include_done: · 80 unmodified lines | ||
| 1860 | 1860 | if (c > 1) |
| 1861 | 1861 | tcc_error("#elif after #else"); |
| 1862 | 1862 | /* last #if/#elif expression was true: we skip */ |
| 1863 | − if (c == 1) | |
| 1864 | − goto skip; | |
| 1865 | − c = expr_preprocess(); | |
| 1866 | − s1->ifdef_stack_ptr[-1] = c; | |
| 1863 | + if (c == 1) { | |
| 1864 | + c = 0; | |
| 1865 | + } else { | |
| 1866 | + c = expr_preprocess(); | |
| 1867 | + s1->ifdef_stack_ptr[-1] = c; | |
| 1868 | + } | |
| 1867 | 1869 | test_else: |
| 1868 | 1870 | if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1) |
| 1869 | 1871 | file->ifndef_macro = 0; |
| 1870 | 1872 | test_skip: |
| 1871 | 1873 | if (!(c & 1)) { |
| 1872 | − skip: | |
| 1873 | 1874 | preprocess_skip(); |
| 1874 | 1875 | is_bof = 0; |
| 1875 | 1876 | goto redo; |
| @@ -1899,10 +1900,10 @@ include_done: · 23 unmodified lines | ||
| 1899 | 1900 | case TOK_LINE: |
| 1900 | 1901 | next(); |
| 1901 | 1902 | if (tok != TOK_CINT) |
| 1902 | −_line_err: | |
| 1903 | + _line_err: | |
| 1903 | 1904 | tcc_error("wrong #line format"); |
| 1904 | 1905 | n = tokc.i; |
| 1905 | −_line_num: | |
| 1906 | + _line_num: | |
| 1906 | 1907 | next(); |
| 1907 | 1908 | if (tok != TOK_LINEFEED) { |
| 1908 | 1909 | if (tok == TOK_STR) |