Skip to content

Commit e318ef2

Browse files
authored
Fix for backtrace error when file not found in: src/fpm_source_parsing.f90 (#675)
1 parent 0806c9e commit e318ef2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/fpm_source_parsing.f90

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
!> - `[[parse_c_source]]`
1616
!>
1717
module fpm_source_parsing
18-
use fpm_error, only: error_t, file_parse_error, fatal_error
18+
use fpm_error, only: error_t, file_parse_error, fatal_error, file_not_found_error
1919
use fpm_strings, only: string_t, string_cat, len_trim, split, lower, str_ends_with, fnv_1a, is_fortran_name
2020
use fpm_model, only: srcfile_t, &
2121
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
2222
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
2323
FPM_UNIT_CSOURCE, FPM_UNIT_CHEADER, FPM_SCOPE_UNKNOWN, &
2424
FPM_SCOPE_LIB, FPM_SCOPE_DEP, FPM_SCOPE_APP, FPM_SCOPE_TEST
25-
use fpm_filesystem, only: read_lines, read_lines_expanded
25+
use fpm_filesystem, only: read_lines, read_lines_expanded, exists
2626
implicit none
2727

2828
private
@@ -81,6 +81,11 @@ function parse_f_source(f_filename,error) result(f_source)
8181
type(string_t), allocatable :: file_lines(:), file_lines_lower(:)
8282
character(:), allocatable :: temp_string, mod_name, string_parts(:)
8383

84+
if (.not. exists(f_filename)) then
85+
call file_not_found_error(error, f_filename)
86+
return
87+
end if
88+
8489
f_source%file_name = f_filename
8590

8691
open(newunit=fh,file=f_filename,status='old')

0 commit comments

Comments
 (0)