Skip to content

Commit f2f3a18

Browse files
committed
fix allocatable array
1 parent 8a80890 commit f2f3a18

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/fpm_source_parsing.f90

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
module fpm_source_parsing
1818
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, &
20-
is_fortran_name, operator(.in.)
20+
is_fortran_name, operator(.in.), operator(==)
2121
use fpm_model, only: srcfile_t, &
2222
FPM_UNIT_UNKNOWN, FPM_UNIT_PROGRAM, FPM_UNIT_MODULE, &
2323
FPM_UNIT_SUBMODULE, FPM_UNIT_SUBPROGRAM, &
@@ -46,12 +46,14 @@ module fpm_source_parsing
4646
!> Case-insensitive check if macro_name is in the macros list
4747
logical function macro_in_list_ci(macro_name, macros)
4848
character(*), intent(in) :: macro_name
49-
type(string_t), intent(in) :: macros(:)
49+
type(string_t), optional, intent(in) :: macros(:)
5050
integer :: i
5151

5252
macro_in_list_ci = .false.
53+
if (.not.present(macros)) return
54+
5355
do i = 1, size(macros)
54-
if (lower(trim(macro_name)) == lower(trim(macros(i)%s))) then
56+
if (string_t(lower(macro_name)) == macros(i)) then
5557
macro_in_list_ci = .true.
5658
return
5759
end if
@@ -138,8 +140,6 @@ subroutine parse_cpp_condition(line, preprocess, is_active, macro_name)
138140
return
139141
endif
140142

141-
is_active = .false.
142-
143143
! There are macros: test if active
144144
if (index(line, '#ifdef') == 1) then
145145
! #ifdef MACRO
@@ -166,6 +166,9 @@ subroutine parse_cpp_condition(line, preprocess, is_active, macro_name)
166166
else
167167
is_active = macro_in_list_ci(macro_name, preprocess%macros)
168168
end if
169+
else
170+
! More complex condition
171+
is_active = .false.
169172
end if
170173
else
171174
! #if MACRO (simple macro check)
@@ -174,6 +177,8 @@ subroutine parse_cpp_condition(line, preprocess, is_active, macro_name)
174177
macro_name = trim(adjustl(line(start_pos:end_pos)))
175178
is_active = macro_in_list_ci(macro_name, preprocess%macros)
176179
end if
180+
else
181+
is_active = .false.
177182
end if
178183

179184
end subroutine parse_cpp_condition

0 commit comments

Comments
 (0)