fix #elif line number problem with parse test
This commit is contained in:
parent
aba654c36d
commit
26fccf7cd7
3 changed files with 1929 additions and 8 deletions
|
@ -1,4 +1,10 @@
|
||||||
#include "tests/parse_stb_sprintf.h"
|
#include "tests/parse_stb_sprintf.h"
|
||||||
|
/* #if 0 */
|
||||||
|
/* #elif 1 */
|
||||||
|
/* int f(){} */
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
|
||||||
/* @TODO: why are line numbers off by 1? */
|
/* @TODO: why are line numbers off by 1? */
|
||||||
int main() {
|
int main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,6 +550,7 @@ function translation_phase_4
|
||||||
|
|
||||||
:phase4_line
|
:phase4_line
|
||||||
line_number += 1
|
line_number += 1
|
||||||
|
:phase4_line_noinc
|
||||||
c = *1in
|
c = *1in
|
||||||
if c == 0 goto phase4_end
|
if c == 0 goto phase4_end
|
||||||
if c == '# goto pp_directive ; NOTE: ## cannot appear at the start of a line
|
if c == '# goto pp_directive ; NOTE: ## cannot appear at the start of a line
|
||||||
|
@ -869,7 +870,7 @@ function translation_phase_4
|
||||||
p = look_up_function_macro(macro_name)
|
p = look_up_function_macro(macro_name)
|
||||||
if p != 0 goto process_pptoken ; macro is defined; keep processing
|
if p != 0 goto process_pptoken ; macro is defined; keep processing
|
||||||
preprocessor_skip_if(filename, &line_number, &in, &out)
|
preprocessor_skip_if(filename, &line_number, &in, &out)
|
||||||
goto process_pptoken
|
goto phase4_line_noinc
|
||||||
:pp_directive_ifndef
|
:pp_directive_ifndef
|
||||||
pptoken_skip(&in)
|
pptoken_skip(&in)
|
||||||
pptoken_skip_spaces(&in)
|
pptoken_skip_spaces(&in)
|
||||||
|
@ -884,12 +885,12 @@ function translation_phase_4
|
||||||
goto process_pptoken ; macro not defined; keep processing
|
goto process_pptoken ; macro not defined; keep processing
|
||||||
:ifndef_skip
|
:ifndef_skip
|
||||||
preprocessor_skip_if(filename, &line_number, &in, &out)
|
preprocessor_skip_if(filename, &line_number, &in, &out)
|
||||||
goto process_pptoken
|
goto phase4_line_noinc
|
||||||
:pp_directive_else
|
:pp_directive_else
|
||||||
; assume we got here from an if, so skip this
|
; assume we got here from an if, so skip this
|
||||||
pptoken_skip_to_newline(&in)
|
pptoken_skip_to_newline(&in)
|
||||||
preprocessor_skip_if(filename, &line_number, &in, &out)
|
preprocessor_skip_if(filename, &line_number, &in, &out)
|
||||||
goto process_pptoken
|
goto phase4_line_noinc
|
||||||
:pp_directive_endif
|
:pp_directive_endif
|
||||||
; assume we got here from an if/elif/else, just ignore it.
|
; assume we got here from an if/elif/else, just ignore it.
|
||||||
pptoken_skip(&in)
|
pptoken_skip(&in)
|
||||||
|
@ -992,7 +993,7 @@ function translation_phase_4
|
||||||
byte 0
|
byte 0
|
||||||
:pp_if_done
|
:pp_if_done
|
||||||
free(if_pptokens)
|
free(if_pptokens)
|
||||||
goto process_pptoken
|
goto phase4_line_noinc
|
||||||
:unrecognized_directive
|
:unrecognized_directive
|
||||||
compile_error(filename, line_number, .str_unrecognized_directive)
|
compile_error(filename, line_number, .str_unrecognized_directive)
|
||||||
:str_unrecognized_directive
|
:str_unrecognized_directive
|
||||||
|
@ -1040,7 +1041,7 @@ function translation_phase_4
|
||||||
|
|
||||||
|
|
||||||
; skip body of #if / #elif / #else. This will advance *p_in to:
|
; skip body of #if / #elif / #else. This will advance *p_in to:
|
||||||
; - right before the next unmatched #elif, replacing it with a #if
|
; - right at the next unmatched #elif, replacing it with a #if
|
||||||
; OR - right after the next #else
|
; OR - right after the next #else
|
||||||
; OR - right after the next #endif
|
; OR - right after the next #endif
|
||||||
; whichever comes first
|
; whichever comes first
|
||||||
|
@ -1104,8 +1105,7 @@ function preprocessor_skip_if
|
||||||
*1in = 'i
|
*1in = 'i
|
||||||
in += 1
|
in += 1
|
||||||
*1in = 'f
|
*1in = 'f
|
||||||
in -= 5
|
in -= 3
|
||||||
*1in = 10 ; we need a newline so the #elif actually gets handled
|
|
||||||
goto preprocessor_skip_if_loop_end
|
goto preprocessor_skip_if_loop_end
|
||||||
:skip_if_inc_depth
|
:skip_if_inc_depth
|
||||||
if_depth += 1
|
if_depth += 1
|
||||||
|
|
1915
05/tests/parse_stb_sprintf.h
Normal file
1915
05/tests/parse_stb_sprintf.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue