Skip to content

Commit d4b81bc

Browse files
committed
Simplify allocation check
1 parent 33561d6 commit d4b81bc

File tree

6 files changed

+47
-43
lines changed

6 files changed

+47
-43
lines changed

src/fpm/dependency.f90

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,13 +1285,17 @@ logical function dependency_node_is_same(this,that)
12851285
if (.not.(this%update.eqv.other%update)) return
12861286
if (.not.(this%cached.eqv.other%cached)) return
12871287

1288-
if (.not. allocated(this%proj_dir) .eqv. allocated(other%proj_dir)) return
1289-
if (.not.(this%proj_dir==other%proj_dir)) return
1290-
if (.not. allocated(this%revision) .eqv. allocated(other%revision)) return
1291-
if (.not.(this%revision==other%revision)) return
1288+
if (allocated(this%proj_dir) .neqv. allocated(other%proj_dir)) return
1289+
if (allocated(this%proj_dir)) then
1290+
if (.not.(this%proj_dir==other%proj_dir)) return
1291+
endif
1292+
if (allocated(this%revision) .neqv. allocated(other%revision)) return
1293+
if (allocated(this%revision)) then
1294+
if (.not.(this%revision==other%revision)) return
1295+
endif
12921296

1293-
if (.not.(allocated(this%version).eqv.allocated(other%version))) return
1294-
if (allocated(this%version)) then
1297+
if (allocated(this%version).neqv.allocated(other%version)) return
1298+
if (allocated(this%version)) then
12951299
if (.not.(this%version==other%version)) return
12961300
endif
12971301

src/fpm/manifest/executable.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,19 @@ logical function exe_is_same(this,that)
206206
select type (other=>that)
207207
type is (executable_config_t)
208208
if (.not.this%link==other%link) return
209-
if (.not.allocated(this%name).eqv.allocated(other%name)) return
210-
if (allocated(this%name).and.allocated(other%name)) then
209+
if (allocated(this%name).neqv.allocated(other%name)) return
210+
if (allocated(this%name)) then
211211
if (.not.this%name==other%name) return
212212
end if
213-
if (.not.allocated(this%source_dir).eqv.allocated(other%source_dir)) return
214-
if (allocated(this%source_dir).and.allocated(other%source_dir)) then
213+
if (allocated(this%source_dir).neqv.allocated(other%source_dir)) return
214+
if (allocated(this%source_dir)) then
215215
if (.not.this%source_dir==other%source_dir) return
216216
end if
217-
if (.not.allocated(this%main).eqv.allocated(other%main)) return
218-
if (allocated(this%main).and.allocated(other%main)) then
217+
if (allocated(this%main).neqv.allocated(other%main)) return
218+
if (allocated(this%main)) then
219219
if (.not.this%main==other%main) return
220220
end if
221-
if (.not.allocated(this%dependency).eqv.allocated(other%dependency)) return
221+
if (allocated(this%dependency).neqv.allocated(other%dependency)) return
222222
if (allocated(this%dependency)) then
223223
if (.not.(size(this%dependency)==size(other%dependency))) return
224224
do ii = 1, size(this%dependency)

src/fpm/manifest/fortran.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ logical function fortran_is_same(this,that)
122122
type is (fortran_config_t)
123123
if (this%implicit_typing.neqv.other%implicit_typing) return
124124
if (this%implicit_external.neqv.other%implicit_external) return
125-
if (.not.allocated(this%source_form).eqv.allocated(other%source_form)) return
126-
if (allocated(this%source_form).and.allocated(other%source_form)) then
125+
if (allocated(this%source_form).neqv.allocated(other%source_form)) return
126+
if (allocated(this%source_form)) then
127127
if (.not.this%source_form==other%source_form) return
128128
end if
129129
class default

src/fpm/manifest/library.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ logical function library_is_same(this,that)
161161
select type (other=>that)
162162
type is (library_config_t)
163163
if (.not.this%include_dir==other%include_dir) return
164-
if (.not.allocated(this%source_dir).eqv.allocated(other%source_dir)) return
165-
if (allocated(this%source_dir).and.allocated(other%source_dir)) then
164+
if (allocated(this%source_dir).neqv.allocated(other%source_dir)) return
165+
if (allocated(this%source_dir)) then
166166
if (.not.this%source_dir==other%source_dir) return
167167
end if
168-
if (.not.allocated(this%build_script).eqv.allocated(other%build_script)) return
169-
if (allocated(this%build_script).and.allocated(other%build_script)) then
168+
if (allocated(this%build_script).neqv.allocated(other%build_script)) return
169+
if (allocated(this%build_script)) then
170170
if (.not.this%build_script==other%build_script) return
171171
end if
172172
class default

src/fpm_compiler.F90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,15 +1342,15 @@ logical function compiler_is_same(this,that)
13421342
type is (compiler_t)
13431343

13441344
if (.not.(this%id==other%id)) return
1345-
if (.not. allocated(this%fc).eqv.allocated(other%fc)) return
1345+
if (allocated(this%fc).neqv.allocated(other%fc)) return
13461346
if (allocated(this%fc)) then
13471347
if (.not.(this%fc==other%fc)) return
13481348
end if
1349-
if (.not. allocated(this%cc).eqv.allocated(other%cc)) return
1349+
if (allocated(this%cc).neqv.allocated(other%cc)) return
13501350
if (allocated(this%cc)) then
13511351
if (.not.(this%cc==other%cc)) return
13521352
end if
1353-
if (.not. allocated(this%cxx).eqv.allocated(other%cxx)) return
1353+
if (allocated(this%cxx).neqv.allocated(other%cxx)) return
13541354
if (allocated(this%cxx)) then
13551355
if (.not.(this%cxx==other%cxx)) return
13561356
end if
@@ -1458,7 +1458,7 @@ logical function check_fortran_source_runs(self, input, compile_flags, link_flag
14581458
class(compiler_t), intent(in) :: self
14591459
!> Program Source
14601460
character(len=*), intent(in) :: input
1461-
!> Optional build and link flags
1461+
!> Optional build and link flags
14621462
character(len=*), optional, intent(in) :: compile_flags, link_flags
14631463

14641464
integer :: stat,unit
@@ -1481,10 +1481,10 @@ logical function check_fortran_source_runs(self, input, compile_flags, link_flag
14811481
!> Get flags
14821482
flags = self%get_default_flags(release=.false.)
14831483
ldflags = self%get_default_flags(release=.false.)
1484-
1484+
14851485
if (present(compile_flags)) flags = flags//" "//compile_flags
14861486
if (present(link_flags)) ldflags = ldflags//" "//link_flags
1487-
1487+
14881488
!> Compile and link program
14891489
call self%compile_fortran(source, object, flags, logf, stat)
14901490
if (stat==0) &
@@ -1518,7 +1518,7 @@ logical function check_flags_supported(self, compile_flags, link_flags)
15181518
character(len=*), parameter :: hello_world = "print *, 'Hello, World!'; end"
15191519

15201520
check_flags_supported = self%check_fortran_source_runs(hello_world, compile_flags, link_flags)
1521-
1521+
15221522
end function check_flags_supported
15231523

15241524
!> Check if the current compiler supports 128-bit real precision

src/fpm_model.f90

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -482,33 +482,33 @@ logical function srcfile_is_same(this,that)
482482
select type (other=>that)
483483
type is (srcfile_t)
484484
if (allocated(this%file_name).neqv.allocated(other%file_name)) return
485-
if (allocated(this%file_name).and.allocated(other%file_name)) then
485+
if (allocated(this%file_name)) then
486486
if (.not.(this%file_name==other%file_name)) return
487487
end if
488488
if (allocated(this%exe_name).neqv.allocated(other%exe_name)) return
489-
if (allocated(this%exe_name).and.allocated(other%exe_name)) then
489+
if (allocated(this%exe_name)) then
490490
if (.not.(this%exe_name==other%exe_name)) return
491491
end if
492492
if (.not.(this%unit_scope==other%unit_scope)) return
493493
if (allocated(this%modules_provided).neqv.allocated(other%modules_provided)) return
494-
if (allocated(this%modules_provided).and.allocated(other%modules_provided)) then
494+
if (allocated(this%modules_provided)) then
495495
if (.not.(this%modules_provided==other%modules_provided)) return
496496
end if
497497
if (.not.(this%unit_type==other%unit_type)) return
498498
if (allocated(this%parent_modules).neqv.allocated(other%parent_modules)) return
499-
if (allocated(this%parent_modules).and.allocated(other%parent_modules)) then
499+
if (allocated(this%parent_modules)) then
500500
if (.not.(this%parent_modules==other%parent_modules)) return
501501
end if
502502
if (allocated(this%modules_used).neqv.allocated(other%modules_used)) return
503-
if (allocated(this%modules_used).and.allocated(other%modules_used)) then
503+
if (allocated(this%modules_used)) then
504504
if (.not.(this%modules_used==other%modules_used)) return
505505
end if
506506
if (allocated(this%include_dependencies).neqv.allocated(other%include_dependencies)) return
507-
if (allocated(this%include_dependencies).and.allocated(other%include_dependencies)) then
507+
if (allocated(this%include_dependencies)) then
508508
if (.not.(this%include_dependencies==other%include_dependencies)) return
509509
end if
510510
if (allocated(this%link_libraries).neqv.allocated(other%link_libraries)) return
511-
if (allocated(this%link_libraries).and.allocated(other%link_libraries)) then
511+
if (allocated(this%link_libraries)) then
512512
if (.not.(this%link_libraries==other%link_libraries)) return
513513
end if
514514
if (.not.(this%digest==other%digest)) return
@@ -620,7 +620,7 @@ logical function fft_is_same(this,that)
620620
if (.not.(this%implicit_typing.eqv.other%implicit_typing)) return
621621
if (.not.(this%implicit_external.eqv.other%implicit_external)) return
622622
if (allocated(this%source_form).neqv.allocated(other%source_form)) return
623-
if (allocated(this%source_form).and.allocated(other%source_form)) then
623+
if (allocated(this%source_form)) then
624624
if (.not.(this%source_form==other%source_form)) return
625625
end if
626626

@@ -880,7 +880,7 @@ logical function model_is_same(this,that)
880880
type is (fpm_model_t)
881881

882882
if ((allocated(this%package_name).neqv.allocated(other%package_name))) return
883-
if (allocated(this%package_name).and.allocated(other%package_name)) then
883+
if (allocated(this%package_name)) then
884884
if (.not.(this%package_name==other%package_name)) return
885885
end if
886886
if (.not.(allocated(this%packages).eqv.allocated(other%packages))) return
@@ -894,35 +894,35 @@ logical function model_is_same(this,that)
894894
if (.not.(this%compiler==other%compiler)) return
895895
if (.not.(this%archiver==other%archiver)) return
896896
if (allocated(this%fortran_compile_flags).neqv.allocated(other%fortran_compile_flags)) return
897-
if (allocated(this%fortran_compile_flags).and.allocated(other%fortran_compile_flags)) then
897+
if (allocated(this%fortran_compile_flags)) then
898898
if (.not.(this%fortran_compile_flags==other%fortran_compile_flags)) return
899899
end if
900900
if (allocated(this%c_compile_flags).neqv.allocated(other%c_compile_flags)) return
901-
if (allocated(this%c_compile_flags).and.allocated(other%c_compile_flags)) then
901+
if (allocated(this%c_compile_flags)) then
902902
if (.not.(this%c_compile_flags==other%c_compile_flags)) return
903903
end if
904904
if (allocated(this%cxx_compile_flags).neqv.allocated(other%cxx_compile_flags)) return
905-
if (allocated(this%cxx_compile_flags).and.allocated(other%cxx_compile_flags)) then
905+
if (allocated(this%cxx_compile_flags)) then
906906
if (.not.(this%cxx_compile_flags==other%cxx_compile_flags)) return
907907
end if
908908
if (allocated(this%link_flags).neqv.allocated(other%link_flags)) return
909-
if (allocated(this%link_flags).and.allocated(other%link_flags)) then
909+
if (allocated(this%link_flags)) then
910910
if (.not.(this%link_flags==other%link_flags)) return
911911
end if
912912
if (allocated(this%build_prefix).neqv.allocated(other%build_prefix)) return
913-
if (allocated(this%build_prefix).and.allocated(other%build_prefix)) then
913+
if (allocated(this%build_prefix)) then
914914
if (.not.(this%build_prefix==other%build_prefix)) return
915915
end if
916916
if (allocated(this%include_dirs).neqv.allocated(other%include_dirs)) return
917-
if (allocated(this%include_dirs).and.allocated(other%include_dirs)) then
917+
if (allocated(this%include_dirs)) then
918918
if (.not.(this%include_dirs==other%include_dirs)) return
919919
end if
920920
if (allocated(this%link_libraries).neqv.allocated(other%link_libraries)) return
921-
if (allocated(this%link_libraries).and.allocated(other%link_libraries)) then
921+
if (allocated(this%link_libraries)) then
922922
if (.not.(this%link_libraries==other%link_libraries)) return
923923
end if
924924
if (allocated(this%external_modules).neqv.allocated(other%external_modules)) return
925-
if (allocated(this%external_modules).and.allocated(other%external_modules)) then
925+
if (allocated(this%external_modules)) then
926926
if (.not.(this%external_modules==other%external_modules)) return
927927
end if
928928
if (.not.(this%deps==other%deps)) return

0 commit comments

Comments
 (0)