From bdc021076029a22d4c9084d03a2fda773a0db3e7 Mon Sep 17 00:00:00 2001 From: KGB99 <80490551+KGB99@users.noreply.github.com> Date: Thu, 11 Jul 2024 23:26:02 +0100 Subject: [PATCH] add cycle statement to lex_body_statements in fixed form tokenizer (#4486) --- integration_tests/CMakeLists.txt | 1 + integration_tests/cycle_and_exit6.f90 | 16 ++++++++++++++++ src/lfortran/parser/fixedform_tokenizer.cpp | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 integration_tests/cycle_and_exit6.f90 diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 51f357c39b..8f545890d0 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -343,6 +343,7 @@ RUN(NAME cycle_and_exit2 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc fortran) RUN(NAME cycle_and_exit3 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME cycle_and_exit4 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME cycle_and_exit5 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) +RUN(NAME cycle_and_exit6 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME goto_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) RUN(NAME goto_02 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc) diff --git a/integration_tests/cycle_and_exit6.f90 b/integration_tests/cycle_and_exit6.f90 new file mode 100644 index 0000000000..64a9a8428d --- /dev/null +++ b/integration_tests/cycle_and_exit6.f90 @@ -0,0 +1,16 @@ +program cycles_stuck +implicit none + +integer :: iiter, maxit +maxit = 5 + +do iiter = 1, maxit + if ( .true. ) then + cycle + print *, "inside loop" + end if +end do + +print *, "End of program." + +end diff --git a/src/lfortran/parser/fixedform_tokenizer.cpp b/src/lfortran/parser/fixedform_tokenizer.cpp index 6bbd9defea..f54fe39f6e 100644 --- a/src/lfortran/parser/fixedform_tokenizer.cpp +++ b/src/lfortran/parser/fixedform_tokenizer.cpp @@ -1068,6 +1068,11 @@ struct FixedFormRecursiveDescent { return true; } + if (next_is(cur, "cycle")){ + push_token_advance(cur, "cycle"); + tokenize_line(cur); + } + if (l != -1) { // Undo the label, as it will be handled later undo_label(cur);