re PR fortran/67982 (Incorrect -Wunused-function warning)
authorDominique d'Humieres <dominiq@lps.ens.fr>
Tue, 3 Nov 2015 18:03:38 +0000 (19:03 +0100)
committerDominique d'Humieres <dominiq@gcc.gnu.org>
Tue, 3 Nov 2015 18:03:38 +0000 (19:03 +0100)
2015-11-03  Dominique d'Humieres <dominiq@lps.ens.fr>

PR fortran/67982
* gfortran.dg/warn_unused_function_3.f90: New test.

From-SVN: r229716

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/warn_unused_function_3.f90 [new file with mode: 0644]

index 14253d1d1b345b5248c5166c408f83736dbaa95e..829e0a8f5001550f2179554d7fe215fe82ac2969 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-03  Dominique d'Humieres <dominiq@lps.ens.fr>
+
+       PR fortran/67982
+       * gfortran.dg/warn_unused_function_3.f90: New test.
+
 2015-11-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/discr45.adb: Only compile the test.
diff --git a/gcc/testsuite/gfortran.dg/warn_unused_function_3.f90 b/gcc/testsuite/gfortran.dg/warn_unused_function_3.f90
new file mode 100644 (file)
index 0000000..63d64ff
--- /dev/null
@@ -0,0 +1,35 @@
+! { dg-do compile }
+! { dg-options "-Wunused-function" }
+!
+! PR 67982: Bogus -Wunused-function warning with contained function
+!
+! Contributed by Joost VandeVondele <Joost dot VandeVondele at mat dot ethz dot ch> 
+
+MODULE base
+  INTERFACE 
+    SUBROUTINE bar_int()
+    END SUBROUTINE 
+  END INTERFACE
+  PUBLIC hook
+  PRIVATE 
+  PROCEDURE(bar_int), POINTER :: hook=>NULL()
+END MODULE base
+
+MODULE foo
+  USE base, ONLY: hook  
+  PUBLIC init
+  PRIVATE 
+CONTAINS
+  SUBROUTINE init()
+     hook=>bar
+  END SUBROUTINE init
+  SUBROUTINE bar()
+     WRITE(6,*) "In bar"
+  END SUBROUTINE 
+END MODULE
+
+USE foo, ONLY: init
+USE base, ONLY: hook
+CALL init()
+CALL hook()
+END