Skip to content

Commit

Permalink
Merge branch 'salt-fm' of github.com:ParaToolsInc/salt
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeekman committed Feb 1, 2025
2 parents c0f7572 + 78fc948 commit d5911a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ if (TEST_FORTRAN)
trivial.f90
return-only.f90
if-stmt.f90
internal-func.f90
)

# Add a smoke test of the fparse-llvm script
Expand All @@ -652,6 +653,16 @@ if (TEST_FORTRAN)
)
endforeach()

add_test(NAME check-internal-func.f90
COMMAND ${CMAKE_COMMAND} -E cat ${CMAKE_BINARY_DIR}/internal-func.inst.F90
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(check-internal-func.f90
PROPERTIES
PASS_REGULAR_EXPRESSION "[\n\r]+[\t ]+&add "
DEPENDS instrument_internal-func.f90
)

set(fortran_compilers_to_test gfortran flang-new)
foreach(compiler IN LISTS fortran_compilers_to_test)
STRING(TOUPPER ${compiler} upper_comp)
Expand Down
2 changes: 2 additions & 0 deletions src/flang_salt_instrument_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ namespace salt::fortran {
}

bool Pre(const Fortran::parser::SubroutineStmt &subroutineStmt) {
isInMainProgram_ = false;
const auto &name = std::get<Fortran::parser::Name>(subroutineStmt.t);
subprogramName_ = name.ToString();
subProgramLine_ = parsing->allCooked().GetSourcePositionRange(name.source)->first.line;
Expand All @@ -230,6 +231,7 @@ namespace salt::fortran {
}

bool Pre(const Fortran::parser::FunctionStmt &functionStmt) {
isInMainProgram_ = false;
const auto &name = std::get<Fortran::parser::Name>(functionStmt.t);
subprogramName_ = name.ToString();
subProgramLine_ = parsing->allCooked().GetSourcePositionRange(name.source)->first.line;
Expand Down
25 changes: 25 additions & 0 deletions tests/fortran/internal-func.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
program main
implicit none

integer :: my_a, my_b
call get_input(my_a, my_b)
print*, my_a, ' + ', my_b, ' = ', add(my_a, my_b)
contains
function add(a, b)
integer, intent(in) :: a, b
integer :: add

add = a + b

return
end function add
subroutine get_input(a, b)
integer, intent(out) :: a, b
print*, 'Add a and b.'
print*, 'First enter a, then enter b:'
! for testing set values instead of reading form stdin
! read*, my_a, my_b
a = 7
b = 6
end subroutine get_input
end program main

0 comments on commit d5911a9

Please sign in to comment.