I’ld like to close PR47266 as FIXED after the commit on trunk and 5.2.1 of the following test extracted from https://gcc.gnu.org/ml/fortran/2011-01/msg00094.html. The test succeeds on trunk and 5.2.1 (see https://gcc.gnu.org/ml/gcc-testresults/2015-11/msg00965.html in which it was included).
OK for trunk and 5.2.1? Dominique Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 229793) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2015-11-10 Dominique d'Humieres <domi...@lps.ens.fr> + + PR fortran/47266 + * gfortran.dg/warn_unused_function_2.f90: Add a new test. + 2015-11-10 Ilya Enkovich <enkovich....@gmail.com> * gcc.target/i386/mask-pack.c: New test. Index: gcc/testsuite/gfortran.dg/module_private_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/module_private_2.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/module_private_2.f90 (working copy) @@ -0,0 +1,34 @@ +! { dg-do compile } +! { dg-options "-O2 -fdump-tree-optimized" } +! +! PR fortran/47266 +! +! Check whether the private procedure "priv" is optimized away +! +module m + implicit none + private :: priv + private :: export1, export2 + public :: pub +contains + integer function priv() + priv = 44 + end function priv + integer function export1() + export1 = 45 + end function export1 + function export2() bind(C) ! { dg-warning "is marked PRIVATE" } + use iso_c_binding, only: c_int + integer(c_int) :: export2 + export2 = 46 + end function export2 + subroutine pub(a,b) + integer :: a + procedure(export1), pointer :: b + a = priv() + b => export1 + end subroutine pub +end module m +! { dg-final { scan-tree-dump-times "priv" 0 "optimized" } } +! { dg-final { scan-tree-dump-times "export1 \\(\\)" 1 "optimized" } } +! { dg-final { scan-tree-dump-times "export2 \\(\\)" 1 "optimized" } }