Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28459 Discussions

Feature request: warn about incorrect intent for nested types

w_l_kleb
Beginner
258 Views
Hi,

I'd like to see the Fortran Intel compiler at least give a warning if nested INTENT(in) contains an assigment, viz,

% cat > intent.f90 << EOF
module types
type elem_type
integer :: ncell
integer, dimension(:), pointer :: cl2g
end type
type grid_type
integer :: nelem
type(elem_type), dimension(:), pointer :: elem
end type
end module

module nested_intents
use types, only: grid_type
contains
subroutine pass_through( grid )
type(grid_type), intent(in) :: grid
call intent_inout( grid )
end subroutine
subroutine intent_inout( grid )
type(grid_type), intent(in) :: grid ! should produce error: grid changed
integer :: i, j
do i = 1,grid%nelem
do j = 1, grid%elem(i)%ncell
grid%elem(i)%cl2g(j) = grid%elem(i)%cl2g(j) + 1
end do
end do
end subroutine
end module
EOF

% ifort --version | head -1
ifort (IFORT) 12.1.3 20120212

% ifort -c -warn -check function_init.f90
[no complaints]

It's antecedent does:

alpha% fort -what
Compaq Fortran V1.2.0-1882
Compaq Fortran Compiler V1.2.0-1882-48BBF

alpha% fort -c intent.f90
f90: Error: intent.f90, line 24: There is an assignment to a dummy symbol with the explicit INTENT(IN) attribute [GRID]
grid%elem(i)%cl2g(j) = grid%elem(i)%cl2g(j) + 1
--------^

Thanks for consideration,
--
Bil, 757.812.1805
0 Kudos
1 Reply
w_l_kleb
Beginner
258 Views
Rescinded -- see discussion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53939
0 Kudos
Reply