Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: initial implementation of implicit_none #506

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ subroutine build_model(model, settings, package, error)
type(string_t) :: include_dir

model%package_name = package%name
model%implicit_none = package%implicit_none

allocate(model%include_dirs(0))
allocate(model%link_libraries(0))
Expand Down
6 changes: 5 additions & 1 deletion src/fpm/manifest/package.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ module fpm_manifest_package
!> Name of the package
character(len=:), allocatable :: name

logical :: implicit_none

!> Package version
type(version_t) :: version

Expand Down Expand Up @@ -132,6 +134,8 @@ subroutine new_package(self, table, root, error)
return
end if

call get_value(table, "implicit_none", self%implicit_none, .false.)

if (len(self%name) <= 0) then
call syntax_error(error, "Package name must be a non-empty string")
return
Expand Down Expand Up @@ -300,7 +304,7 @@ subroutine check(table, error)
case("version", "license", "author", "maintainer", "copyright", &
& "description", "keywords", "categories", "homepage", "build", &
& "dependencies", "dev-dependencies", "test", "executable", &
& "example", "library", "install")
& "example", "library", "install", "implicit_none")
continue

end select
Expand Down
9 changes: 7 additions & 2 deletions src/fpm_backend.f90
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ subroutine build_target(model,target,stat)
integer, intent(out) :: stat

integer :: ilib, fh
character(:), allocatable :: link_flags
character(:), allocatable :: link_flags, implicit_flag

if (.not.exists(dirname(target%output_file))) then
call mkdir(dirname(target%output_file))
Expand All @@ -266,7 +266,12 @@ subroutine build_target(model,target,stat)
select case(target%target_type)

case (FPM_TARGET_OBJECT)
call run(model%fortran_compiler//" -c " // target%source%file_name // target%compile_flags &
if (model%implicit_none) then
implicit_flag = " -fimplicit-none"
else
implicit_flag = ""
end if
Comment on lines +269 to +273
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like the right place to add this option. At this point we are not aware which compiler we are using anymore and cannot be sure that we are actually passing the correct flag.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see the first TODO item.

call run(model%fortran_compiler//" -c " // target%source%file_name // target%compile_flags // implicit_flag &
// " -o " // target%output_file, echo=.true., exitstat=stat)

case (FPM_TARGET_C_OBJECT)
Expand Down
13 changes: 12 additions & 1 deletion src/fpm_model.f90
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ module fpm_model
!> Name of root package
character(:), allocatable :: package_name

!> Should "implicit none" be enforced by the compiler
logical :: implicit_none

!> Array of packages (including the root package)
type(package_t), allocatable :: packages(:)

Expand Down Expand Up @@ -259,12 +262,20 @@ end function info_srcfile_short

function info_model(model) result(s)
type(fpm_model_t), intent(in) :: model
character(:), allocatable :: s
character(:), allocatable :: s, tmp
integer :: i
!type :: fpm_model_t
s = "fpm_model_t("
! character(:), allocatable :: package_name
s = s // 'package_name="' // model%package_name // '"'

if (model%implicit_none) then
tmp = ".true."
else
tmp = ".false."
end if
s = s // ', implicit_none=' // tmp

! type(srcfile_t), allocatable :: sources(:)
s = s // ", packages=["
do i = 1, size(model%packages)
Expand Down