https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87251
Bug ID: 87251 Summary: warn about unnecessary USE statements Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: janus at gcc dot gnu.org Target Milestone: --- It would be nice if gfortran had diagnostics to warn about unnecessary USE statements, e.g. via a flag "-Wunused-module" or similar (analogous to the flags that warn about unused variables, parameters or dummy arguments). In small program, extraneous USE statements are usually easy to detect and don't do much harm. In a large code base with many modules and dependencies, it becomes increasingly harder to check all of them and get rid of unnecessary ones. One harmful effect of extra USE statements can be an increase of compile time by additional module dependencies, or also by strongly increasing the number of symbols that a compiler has to deal with in a given namespace (for large modules with default public accessibility, such effects can quickly potentiate in dependency chains). Simple test case (where the dependency of 'b' on 'a' is for real, while the dependency of 'c' on 'a' is bogus and can be removed): module a integer :: x,y,z contains subroutine sub() end subroutine end module b use a contains subroutine tub call sub end subroutine end module module c use a contains subroutine cub print *, "..." end subroutine end module