summaryrefslogtreecommitdiff
path: root/Tests/Fortran
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Fortran')
-rw-r--r--Tests/Fortran/CMakeLists.txt220
-rw-r--r--Tests/Fortran/Executable/CMakeLists.txt8
-rw-r--r--Tests/Fortran/Executable/main.f906
-rw-r--r--Tests/Fortran/External/CMakeLists.txt4
-rw-r--r--Tests/Fortran/External/a.f907
-rw-r--r--Tests/Fortran/Library/CMakeLists.txt11
-rw-r--r--Tests/Fortran/Library/a.f903
-rw-r--r--Tests/Fortran/Library/b.f902
-rw-r--r--Tests/Fortran/Library/main.f903
-rw-r--r--Tests/Fortran/foo.f9
-rw-r--r--Tests/Fortran/hello.f6
-rw-r--r--Tests/Fortran/in_interface/main.f903
-rw-r--r--Tests/Fortran/in_interface/module.f9012
-rw-r--r--Tests/Fortran/include/test_preprocess.h5
-rw-r--r--Tests/Fortran/mainc.c5
-rw-r--r--Tests/Fortran/maincxx.c6
-rw-r--r--Tests/Fortran/myc.c12
-rw-r--r--Tests/Fortran/mycxx.cxx6
-rw-r--r--Tests/Fortran/mysub.f5
-rw-r--r--Tests/Fortran/test_module_implementation.f906
-rw-r--r--Tests/Fortran/test_module_interface.f909
-rw-r--r--Tests/Fortran/test_module_main.f904
-rw-r--r--Tests/Fortran/test_preprocess.F9051
-rw-r--r--Tests/Fortran/test_use_in_comment_fixedform.f7
-rw-r--r--Tests/Fortran/test_use_in_comment_freeform.f907
-rw-r--r--Tests/Fortran/testf.f7
-rw-r--r--Tests/Fortran/world.f6
-rw-r--r--Tests/Fortran/world_gnu.def2
-rw-r--r--Tests/Fortran/world_icl.def2
29 files changed, 434 insertions, 0 deletions
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
new file mode 100644
index 000000000..a995f68dd
--- /dev/null
+++ b/Tests/Fortran/CMakeLists.txt
@@ -0,0 +1,220 @@
+cmake_minimum_required (VERSION 2.6)
+project(testf C CXX Fortran)
+message("CTEST_FULL_OUTPUT ")
+set(CMAKE_VERBOSE_MAKEFILE 1)
+message("ENV_FLAGS = $ENV{FFLAGS}")
+message("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}")
+message("CMAKE_Fortran_COMPILER_FULLPATH = ${CMAKE_Fortran_COMPILER_FULLPATH}")
+message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}")
+message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
+
+set(_SHARED SHARED)
+if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(XL|VisualAge)$")
+ # We do not implement SHARED Fortran libs on AIX yet!
+ # Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits.
+ set(_SHARED STATIC)
+elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
+ # g77 2.96 does not support shared libs on Itanium because g2c is not -fPIC
+ execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version
+ OUTPUT_VARIABLE output ERROR_VARIABLE output)
+ if("${output}" MATCHES "Red Hat .* 2\\.96")
+ set(_SHARED STATIC)
+ endif()
+endif()
+
+# Pick a module .def file with the properly mangled symbol name.
+set(world_def "")
+if(WIN32 AND NOT CYGWIN)
+ if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+ set(world_def world_gnu.def)
+ elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" OR
+ "${CMAKE_GENERATOR}" MATCHES "Visual Studio") # Intel plugin
+ set(world_def world_icl.def)
+ endif()
+endif()
+
+add_library(hello STATIC hello.f)
+add_library(world ${_SHARED} world.f ${world_def})
+add_executable(testf testf.f)
+target_link_libraries(testf hello world)
+
+function(test_fortran_c_interface_module)
+ message(STATUS "Testing FortranCInterface module")
+ # test the C to Fortran interface module
+ include(FortranCInterface)
+ FortranCInterface_VERIFY()
+ FortranCInterface_VERIFY(CXX)
+ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
+ if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft")
+ set(module_expected 1)
+ endif()
+ if(FortranCInterface_MODULE_FOUND OR module_expected)
+ set(srcs foo.f)
+ set(FORTRAN_FUNCTIONS test_mod:sub)
+ set(MYC_DEFS TEST_MOD)
+ else()
+ message("${CMAKE_Fortran_COMPILER_ID} compilers do not support"
+ " linking Fortran module procedures from C")
+ endif()
+ endif()
+ list(APPEND FORTRAN_FUNCTIONS my_sub mysub)
+ FortranCInterface_HEADER(foo.h
+ MACRO_NAMESPACE "FC_"
+ SYMBOL_NAMESPACE "F_"
+ SYMBOLS ${FORTRAN_FUNCTIONS}
+ )
+ include_directories("${testf_BINARY_DIR}")
+
+ # if the name mangling is not found for a F90 compiler
+ # print out some diagnostic stuff for the dashboard
+ if(NOT FortranCInterface_GLOBAL_FOUND OR
+ (NOT FortranCInterface_MODULE_FOUND AND module_expected) )
+ find_program(FortranCInterface_EXE
+ NAMES FortranCInterface
+ PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Debug
+ NO_DEFAULT_PATH
+ )
+ find_program(DUMPBIN dumpbin)
+ find_program(NM nm)
+ if(FortranCInterface_EXE)
+ if(DEPENDS)
+ execute_process(COMMAND ${DUMPBIN} /symbols "${FortranCInterface_EXE}"
+ OUTPUT_VARIABLE out)
+ message("symbols in ${FortranCInterface_EXE}:\n${out}")
+ endif()
+ if(NM)
+ execute_process(COMMAND ${NM} "${FortranCInterface_EXE}"
+ OUTPUT_VARIABLE out)
+ message("symbols in ${FortranCInterface_EXE}:\n${out}")
+ endif()
+ endif()
+ endif()
+ message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
+ message("C = ${CMAKE_C_COMPILER_ID}")
+
+ add_library(myfort mysub.f ${srcs})
+
+ add_library(myc myc.c)
+ target_link_libraries(myc myfort)
+ set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS})
+
+ add_library(mycxx mycxx.cxx)
+ target_link_libraries(mycxx myc)
+
+ add_executable(mainc mainc.c)
+ target_link_libraries(mainc myc)
+ add_executable(maincxx maincxx.c)
+ target_link_libraries(maincxx mycxx)
+
+ # print out some stuff to help debug on machines via cdash
+ file(READ "${testf_BINARY_DIR}/foo.h" fooh)
+ message("foo.h contents:\n${fooh}")
+endfunction()
+
+# if the id's match or the compilers are compatible, then
+# call the test_fortran_c_interface_module function
+if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES
+ "(Intel:MSVC|Absoft:GNU)"
+ OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" ))
+ test_fortran_c_interface_module()
+else()
+ message("Fortran does not match c compiler")
+ message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
+ message("C = ${CMAKE_C_COMPILER_ID}")
+ # hack to make g77 work after CL has been enabled
+ # as a languge, cmake needs language specific versions
+ # of these variables....
+ if(WIN32 AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
+ set(CMAKE_CREATE_CONSOLE_EXE )
+ set(CMAKE_LIBRARY_PATH_FLAG "-L")
+ set(CMAKE_LINK_LIBRARY_FLAG "-l")
+ set(CMAKE_LINK_LIBRARY_SUFFIX )
+ endif()
+ # gnu and sunpro do not use the same flags here...
+ # however if LDFLAGS is used to set -m64 it causes odd stuf
+ # with the fortran build
+ if( ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
+ AND ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "SunPro"))
+ set(CMAKE_EXE_LINKER_FLAGS "")
+ set(CMAKE_Fortran_FLAGS "")
+ endif()
+
+endif()
+
+
+
+
+set(TEST_MODULE_DEPENDS 0)
+if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
+ add_executable(test_module
+ test_module_main.f90
+ test_module_implementation.f90
+ test_module_interface.f90)
+
+ add_executable(test_use_in_comment_fixedform
+ test_use_in_comment_fixedform.f)
+ set_property(SOURCE test_use_in_comment_fixedform.f PROPERTY Fortran_FORMAT FIXED)
+ add_executable(test_use_in_comment_freeform
+ test_use_in_comment_freeform.f90)
+ set_property(SOURCE test_use_in_comment_freeform.f90 PROPERTY Fortran_FORMAT FREE)
+
+ add_executable(test_in_interface
+ in_interface/main.f90
+ in_interface/module.f90)
+
+ add_definitions(-DFOO -DBAR=1)
+ include_directories(${testf_SOURCE_DIR}/include)
+ add_executable(test_preprocess test_preprocess.F90)
+
+ set(TEST_MODULE_DEPENDS 1)
+endif(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
+
+if(TEST_MODULE_DEPENDS)
+ # Build the external project separately using a custom target.
+ # Make sure it uses the same build configuration as this test.
+ if(CMAKE_CONFIGURATION_TYPES)
+ set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
+ set(External_BUILD_TYPE)
+ else(CMAKE_CONFIGURATION_TYPES)
+ set(External_CONFIG_TYPE)
+ set(External_BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
+ endif(CMAKE_CONFIGURATION_TYPES)
+ set(External_SOURCE_DIR "${testf_SOURCE_DIR}/External")
+ set(External_BINARY_DIR "${testf_BINARY_DIR}/External")
+ if("${testf_BINARY_DIR}" MATCHES " ")
+ # Our build tree has a space, so the build tool supports spaces.
+ # Test using modules from a path with spaces.
+ set(External_BINARY_DIR "${External_BINARY_DIR} Build")
+ endif()
+ add_custom_command(
+ OUTPUT ${testf_BINARY_DIR}/ExternalProject
+ COMMAND ${CMAKE_CTEST_COMMAND}
+ ARGS ${External_CONFIG_TYPE}
+ --build-and-test
+ ${External_SOURCE_DIR}
+ ${External_BINARY_DIR}
+ --build-noclean
+ --build-two-config
+ --build-project ExtFort
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-options -DCMAKE_Fortran_COMPILER:STRING=${CMAKE_Fortran_COMPILER}
+ -DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}
+ -DCMAKE_Fortran_FLAGS_DEBUG:STRING=${CMAKE_Fortran_FLAGS_DEBUG}
+ -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}
+ -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL}
+ -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}
+ ${External_BUILD_TYPE}
+ )
+ add_custom_target(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject)
+
+ # Test module output directory if available.
+ if(CMAKE_Fortran_MODDIR_FLAG)
+ set(Library_MODDIR "${testf_BINARY_DIR}/Library/modules")
+ else(CMAKE_Fortran_MODDIR_FLAG)
+ set(Library_MODDIR "${testf_BINARY_DIR}/Library")
+ endif(CMAKE_Fortran_MODDIR_FLAG)
+
+ add_subdirectory(Library)
+ add_subdirectory(Executable)
+endif(TEST_MODULE_DEPENDS)
diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt
new file mode 100644
index 000000000..55f21ad46
--- /dev/null
+++ b/Tests/Fortran/Executable/CMakeLists.txt
@@ -0,0 +1,8 @@
+include_directories(${Library_MODDIR})
+include_directories(${External_BINARY_DIR})
+link_directories(${External_BINARY_DIR})
+
+add_executable(subdir_exe2 main.f90)
+target_link_libraries(subdir_exe2 subdir_mods)
+add_dependencies(subdir_exe2 ExternalTarget)
+target_link_libraries(subdir_exe2 myext)
diff --git a/Tests/Fortran/Executable/main.f90 b/Tests/Fortran/Executable/main.f90
new file mode 100644
index 000000000..f21156cda
--- /dev/null
+++ b/Tests/Fortran/Executable/main.f90
@@ -0,0 +1,6 @@
+PROGRAM MAINF90
+ USE libraryModuleA
+ USE libraryModuleB
+ USE externalMod
+ CALL printExtModGreeting
+END PROGRAM MAINF90
diff --git a/Tests/Fortran/External/CMakeLists.txt b/Tests/Fortran/External/CMakeLists.txt
new file mode 100644
index 000000000..0eb1cfeed
--- /dev/null
+++ b/Tests/Fortran/External/CMakeLists.txt
@@ -0,0 +1,4 @@
+project(ExtFort Fortran)
+
+add_library(myext a.f90)
+
diff --git a/Tests/Fortran/External/a.f90 b/Tests/Fortran/External/a.f90
new file mode 100644
index 000000000..2be73c53c
--- /dev/null
+++ b/Tests/Fortran/External/a.f90
@@ -0,0 +1,7 @@
+MODULE externalMod
+!
+CONTAINS
+ SUBROUTINE printExtModGreeting
+ WRITE(*,*) "Greetings from Module externalMod"
+ END SUBROUTINE
+END MODULE
diff --git a/Tests/Fortran/Library/CMakeLists.txt b/Tests/Fortran/Library/CMakeLists.txt
new file mode 100644
index 000000000..fe1368a07
--- /dev/null
+++ b/Tests/Fortran/Library/CMakeLists.txt
@@ -0,0 +1,11 @@
+INCLUDE_DIRECTORIES(${Library_MODDIR})
+ADD_LIBRARY(subdir_mods a.f90 b.f90)
+ADD_EXECUTABLE(subdir_exe main.f90)
+TARGET_LINK_LIBRARIES(subdir_exe subdir_mods)
+
+# Test module output directory if available.
+IF(CMAKE_Fortran_MODDIR_FLAG)
+ SET_TARGET_PROPERTIES(subdir_mods PROPERTIES
+ Fortran_MODULE_DIRECTORY modules
+ )
+ENDIF(CMAKE_Fortran_MODDIR_FLAG)
diff --git a/Tests/Fortran/Library/a.f90 b/Tests/Fortran/Library/a.f90
new file mode 100644
index 000000000..3031c0723
--- /dev/null
+++ b/Tests/Fortran/Library/a.f90
@@ -0,0 +1,3 @@
+MODULE libraryModuleA
+ USE libraryModuleB
+END MODULE
diff --git a/Tests/Fortran/Library/b.f90 b/Tests/Fortran/Library/b.f90
new file mode 100644
index 000000000..ae1edcb20
--- /dev/null
+++ b/Tests/Fortran/Library/b.f90
@@ -0,0 +1,2 @@
+MODULE libraryModuleB
+END MODULE
diff --git a/Tests/Fortran/Library/main.f90 b/Tests/Fortran/Library/main.f90
new file mode 100644
index 000000000..2385408a2
--- /dev/null
+++ b/Tests/Fortran/Library/main.f90
@@ -0,0 +1,3 @@
+PROGRAM MAINF90
+ USE libraryModuleA
+END PROGRAM MAINF90
diff --git a/Tests/Fortran/foo.f b/Tests/Fortran/foo.f
new file mode 100644
index 000000000..dbbb3a4e9
--- /dev/null
+++ b/Tests/Fortran/foo.f
@@ -0,0 +1,9 @@
+ module test_mod
+ interface dummy
+ module procedure sub
+ end interface
+ contains
+ subroutine sub
+ end subroutine
+
+ end module test_mod
diff --git a/Tests/Fortran/hello.f b/Tests/Fortran/hello.f
new file mode 100644
index 000000000..aa0de7715
--- /dev/null
+++ b/Tests/Fortran/hello.f
@@ -0,0 +1,6 @@
+ SUBROUTINE HELLO
+
+ PRINT *, 'Hello'
+
+ END
+
diff --git a/Tests/Fortran/in_interface/main.f90 b/Tests/Fortran/in_interface/main.f90
new file mode 100644
index 000000000..28bcf36d5
--- /dev/null
+++ b/Tests/Fortran/in_interface/main.f90
@@ -0,0 +1,3 @@
+program hello
+ use test_interface
+end program hello
diff --git a/Tests/Fortran/in_interface/module.f90 b/Tests/Fortran/in_interface/module.f90
new file mode 100644
index 000000000..1064d74b0
--- /dev/null
+++ b/Tests/Fortran/in_interface/module.f90
@@ -0,0 +1,12 @@
+module test_interface
+
+ interface dummy
+ module procedure module_function
+ end interface
+
+contains
+
+ subroutine module_function
+ end subroutine
+
+end module test_interface \ No newline at end of file
diff --git a/Tests/Fortran/include/test_preprocess.h b/Tests/Fortran/include/test_preprocess.h
new file mode 100644
index 000000000..29ac4b65f
--- /dev/null
+++ b/Tests/Fortran/include/test_preprocess.h
@@ -0,0 +1,5 @@
+#ifdef BAR
+ PRINT * , 'BAR was defined via ADD_DEFINITIONS'
+#else
+ PRINT *, 'If you can read this something went wrong'
+#endif
diff --git a/Tests/Fortran/mainc.c b/Tests/Fortran/mainc.c
new file mode 100644
index 000000000..9efafc5c0
--- /dev/null
+++ b/Tests/Fortran/mainc.c
@@ -0,0 +1,5 @@
+extern int myc(void);
+int main()
+{
+ return myc();
+}
diff --git a/Tests/Fortran/maincxx.c b/Tests/Fortran/maincxx.c
new file mode 100644
index 000000000..d35ea7e25
--- /dev/null
+++ b/Tests/Fortran/maincxx.c
@@ -0,0 +1,6 @@
+extern int myc(void);
+extern int mycxx(void);
+int main()
+{
+ return myc() + mycxx();
+}
diff --git a/Tests/Fortran/myc.c b/Tests/Fortran/myc.c
new file mode 100644
index 000000000..efd9b68aa
--- /dev/null
+++ b/Tests/Fortran/myc.c
@@ -0,0 +1,12 @@
+#include "foo.h"
+extern F_test_mod_sub(void);
+extern F_mysub(void);
+int myc(void)
+{
+ F_mysub();
+ F_my_sub();
+#ifdef TEST_MOD
+ F_test_mod_sub();
+#endif
+ return 0;
+}
diff --git a/Tests/Fortran/mycxx.cxx b/Tests/Fortran/mycxx.cxx
new file mode 100644
index 000000000..bf04062ed
--- /dev/null
+++ b/Tests/Fortran/mycxx.cxx
@@ -0,0 +1,6 @@
+extern "C" int myc(void);
+extern "C" int mycxx(void)
+{
+ delete new int;
+ return myc();
+}
diff --git a/Tests/Fortran/mysub.f b/Tests/Fortran/mysub.f
new file mode 100644
index 000000000..4b108e333
--- /dev/null
+++ b/Tests/Fortran/mysub.f
@@ -0,0 +1,5 @@
+ subroutine mysub
+ print *, 'Printing this requires fortran language libraries'
+ end subroutine
+ subroutine my_sub
+ end subroutine
diff --git a/Tests/Fortran/test_module_implementation.f90 b/Tests/Fortran/test_module_implementation.f90
new file mode 100644
index 000000000..de3cb574c
--- /dev/null
+++ b/Tests/Fortran/test_module_implementation.f90
@@ -0,0 +1,6 @@
+FUNCTION TEST_MODULE_FUNCTION(A,B)
+ REAL :: TEST_MODULE_FUNCTION
+ REAL, INTENT(IN) :: A
+ REAL, INTENT(IN) :: B
+ TEST_MODULE_FUNCTION = A + B
+END FUNCTION TEST_MODULE_FUNCTION
diff --git a/Tests/Fortran/test_module_interface.f90 b/Tests/Fortran/test_module_interface.f90
new file mode 100644
index 000000000..dd0f35c56
--- /dev/null
+++ b/Tests/Fortran/test_module_interface.f90
@@ -0,0 +1,9 @@
+MODULE TEST_MODULE
+ INTERFACE
+ FUNCTION TEST_MODULE_FUNCTION(A,B)
+ REAL :: TEST_MODULE_FUNCTION
+ REAL, INTENT(IN) :: A
+ REAL, INTENT(IN) :: B
+ END FUNCTION TEST_MODULE_FUNCTION
+ END INTERFACE
+END MODULE TEST_MODULE
diff --git a/Tests/Fortran/test_module_main.f90 b/Tests/Fortran/test_module_main.f90
new file mode 100644
index 000000000..6ac97fa91
--- /dev/null
+++ b/Tests/Fortran/test_module_main.f90
@@ -0,0 +1,4 @@
+PROGRAM MAINF90
+ USE TEST_MODULE
+ PRINT *,'Sum is',TEST_MODULE_FUNCTION(1., 2.)
+END PROGRAM MAINF90
diff --git a/Tests/Fortran/test_preprocess.F90 b/Tests/Fortran/test_preprocess.F90
new file mode 100644
index 000000000..e4f1fbe76
--- /dev/null
+++ b/Tests/Fortran/test_preprocess.F90
@@ -0,0 +1,51 @@
+MODULE Available
+! no conent
+END MODULE
+
+PROGRAM PPTEST
+! value of InPPFalseBranch ; values of SkipToEnd
+! 0 <empty>
+#ifndef FOO
+ ! 1 ; <0>
+ USE NotAvailable
+# ifndef FOO
+ ! 2 ; <0,0>
+ USE NotAvailable
+# else
+ ! 2 ; <0,0>
+ USE NotAvailable
+# endif
+ ! 1 ; <0>
+# ifdef FOO
+ ! 2 ; <0,1>
+ USE NotAvailable
+# else
+ ! 2 ; <0,1>
+ USE NotAvailable
+# endif
+ ! 1 ; <0>
+#else
+ ! 0 ; <0>
+ USE Available
+# ifndef FOO
+ ! 1 ; <0,0>
+ USE NotAvailable
+# else
+ ! 0 ; <0,0>
+ USE Available
+# endif
+ ! 0 ; <0>
+# ifdef FOO
+ ! 0 ; <0,1>
+ USE Available
+# else
+ ! 1 ; <0,1>
+ USE NotAvailable
+# endif
+ ! 0 ; <0>
+#endif
+! 0 ; <empty>
+
+#include "test_preprocess.h"
+
+END PROGRAM
diff --git a/Tests/Fortran/test_use_in_comment_fixedform.f b/Tests/Fortran/test_use_in_comment_fixedform.f
new file mode 100644
index 000000000..39f486bf9
--- /dev/null
+++ b/Tests/Fortran/test_use_in_comment_fixedform.f
@@ -0,0 +1,7 @@
+ PROGRAM foo
+! USE bar
+! use bar
+! Use bar
+
+ WRITE(*,*) 'Hello, Fortran world.'
+ END PROGRAM
diff --git a/Tests/Fortran/test_use_in_comment_freeform.f90 b/Tests/Fortran/test_use_in_comment_freeform.f90
new file mode 100644
index 000000000..c992a041b
--- /dev/null
+++ b/Tests/Fortran/test_use_in_comment_freeform.f90
@@ -0,0 +1,7 @@
+PROGRAM foo
+! USE bar
+! use bar
+! Use bar
+
+ WRITE(*,*) 'Hello, Fortran world.'
+END PROGRAM
diff --git a/Tests/Fortran/testf.f b/Tests/Fortran/testf.f
new file mode 100644
index 000000000..abf6c6df7
--- /dev/null
+++ b/Tests/Fortran/testf.f
@@ -0,0 +1,7 @@
+ PROGRAM TESTF
+
+ CALL HELLO()
+ CALL WORLD()
+
+ END
+
diff --git a/Tests/Fortran/world.f b/Tests/Fortran/world.f
new file mode 100644
index 000000000..0487dffe4
--- /dev/null
+++ b/Tests/Fortran/world.f
@@ -0,0 +1,6 @@
+ SUBROUTINE WORLD
+
+ PRINT *, 'World!'
+
+ END
+
diff --git a/Tests/Fortran/world_gnu.def b/Tests/Fortran/world_gnu.def
new file mode 100644
index 000000000..161779877
--- /dev/null
+++ b/Tests/Fortran/world_gnu.def
@@ -0,0 +1,2 @@
+EXPORTS
+ world_
diff --git a/Tests/Fortran/world_icl.def b/Tests/Fortran/world_icl.def
new file mode 100644
index 000000000..ead7710cd
--- /dev/null
+++ b/Tests/Fortran/world_icl.def
@@ -0,0 +1,2 @@
+EXPORTS
+ WORLD