------- Comment #2 from dominiq at lps dot ens dot fr 2008-11-12 16:12 ------- With the patch for pr38065, compiling gfortran.dg/private_type_4.f90 without -std=f95 does not return the expected error:
/opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/private_type_4.f90:14.24: type(t1) function f1() ! { dg-error "cannot be of PRIVATE type" } 1 Error: PUBLIC function 'f1' at (1) cannot be of PRIVATE type 't1' So if the code is f2003 compliant the fix is obvious: just add the -std=f95 as a dg option. In this case I have a question: if 'f1' is public, how is it supposed to be used in the program? There is also a glitch: with -std=f95 the error /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/private_type_4.f90:14.24: type(t1) function f1() ! { dg-error "cannot be of PRIVATE type" } 1 Error: Fortran 2003: PUBLIC variable 'f1' at (1) of PRIVATE derived type 't1' is emitted twice and with gfortran 4.3.2 I get /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/private_type_4.f90:14.24: type(t1) function f1() ! { dg-error "cannot be of PRIVATE type" } 1 Error: Fortran 2003: PUBLIC variable 'f1' at (1) of PRIVATE derived type 't1' /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/private_type_4.f90:14.24: type(t1) function f1() ! { dg-error "cannot be of PRIVATE type" } 1 Error: Fortran 2003: PUBLIC variable 'f1' at (1) of PRIVATE derived type 't1' /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/private_type_4.f90:14.24: type(t1) function f1() ! { dg-error "cannot be of PRIVATE type" } 1 Error: PUBLIC function 'f1' at (1) cannot be of PRIVATE type 't1' -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38094