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

Feature request: warn if private type is used by public declaration

w_l_kleb
Beginner
291 Views
Hi,

I'd like to see the Intel Fortran compiler at least give a warning if a PRIVATE TYPE is used for a PUBLIC declaration, viz,

% cat > pub_var_private_type.f90 << EOF
module pub_var_private_type
type, private :: private_type
integer :: sample
end type
type(private_type), public :: var ! should produce error
end module
EOF

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

% ifort -c -warn -check pub_var_private_type.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 pub_var_private_type.f90
f90: Error: pub_var_private_type.f90, line 5: This entity cannot be PUBLIC since its derived type is PRIVATE. [VAR]
type(private_type), public :: var ! should produce error
--------------------------------^

Thanks for consideration,
--
Bil, 757.812.1805
0 Kudos
4 Replies
w_l_kleb
Beginner
291 Views
Upon reading the GCC bug report, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40089, it seems that this might just be the old Fortran 95 fort compiler complaining whereas F2003 allows this?
0 Kudos
Steven_L_Intel1
Employee
291 Views
Correct - this was an enhancement in Fortran 2003. You can use -std95 if you want the warning.
0 Kudos
w_l_kleb
Beginner
291 Views
Ah, yes, thanks. I read that one but missed the F95 subtlety.
0 Kudos
w_l_kleb
Beginner
291 Views
0 Kudos
Reply