aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-09-26 12:06:15 +0100
committerLKedward <laurence.kedward@bristol.ac.uk>2020-09-26 12:06:15 +0100
commit70f00392111c72b26612a4dbad20f1cdbc89f8d8 (patch)
tree7c1e97123d5be18eee01bc6b0f31e247a003f142
parent8c558743ecad4f21f9695f81826326c5a14ee93f (diff)
downloadfpm-70f00392111c72b26612a4dbad20f1cdbc89f8d8.tar.gz
fpm-70f00392111c72b26612a4dbad20f1cdbc89f8d8.zip
Add: error handling to module dependency resolution
to allow testing.
-rw-r--r--fpm/src/fpm.f902
-rw-r--r--fpm/src/fpm_sources.f9014
2 files changed, 9 insertions, 7 deletions
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90
index 0047ed4..ec7659a 100644
--- a/fpm/src/fpm.f90
+++ b/fpm/src/fpm.f90
@@ -87,7 +87,7 @@ subroutine build_model(model, settings, package, error)
end if
- call resolve_module_dependencies(model%sources)
+ call resolve_module_dependencies(model%sources,error)
end subroutine build_model
diff --git a/fpm/src/fpm_sources.f90 b/fpm/src/fpm_sources.f90
index 448174e..266e52a 100644
--- a/fpm/src/fpm_sources.f90
+++ b/fpm/src/fpm_sources.f90
@@ -1,5 +1,5 @@
module fpm_sources
-use fpm_error, only: error_t, file_parse_error
+use fpm_error, only: error_t, file_parse_error, fatal_error
use fpm_model, only: srcfile_ptr, srcfile_t, fpm_model_t, &
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
@@ -549,11 +549,12 @@ function split_n(string,delims,n,stat) result(substring)
end function split_n
-subroutine resolve_module_dependencies(sources)
+subroutine resolve_module_dependencies(sources,error)
! After enumerating all source files: resolve file dependencies
! by searching on module names
!
type(srcfile_t), intent(inout), target :: sources(:)
+ type(error_t), allocatable, intent(out) :: error
type(srcfile_ptr) :: dep
@@ -583,10 +584,11 @@ subroutine resolve_module_dependencies(sources)
end if
if (.not.associated(dep%ptr)) then
- write(*,*) '(!) Unable to find source for module dependency: ', &
- sources(i)%modules_used(j)%s
- write(*,*) ' for file ',sources(i)%file_name
- error stop
+ call fatal_error(error, &
+ 'Unable to find source for module dependency: "' // &
+ sources(i)%modules_used(j)%s // &
+ '" used by "'//sources(i)%file_name//'"')
+ return
end if
n_depend = n_depend + 1