[flang] Add a .mod file test with subprograms
authorTim Keith <tkeith@nvidia.com>
Mon, 16 Jul 2018 23:44:07 +0000 (16:44 -0700)
committerTim Keith <tkeith@nvidia.com>
Mon, 16 Jul 2018 23:44:07 +0000 (16:44 -0700)
The .mod file just contains the API. Test that prefixes and suffixes
on the declaration get correctly persisted.

Original-commit: flang-compiler/f18@eb2a6deb4fe12bae83fc3cb2366d056cf50cc9a5
Reviewed-on: https://github.com/flang-compiler/f18/pull/126
Tree-same-pre-rewrite: false

flang/test/semantics/CMakeLists.txt
flang/test/semantics/modfile04.f90 [new file with mode: 0644]

index 3ab490d..32d4227 100644 (file)
@@ -60,6 +60,7 @@ set(MODFILE_TESTS
   modfile01.f90
   modfile02.f90
   modfile03.f90
+  modfile04.f90
 )
 
 foreach(test ${ERROR_TESTS})
diff --git a/flang/test/semantics/modfile04.f90 b/flang/test/semantics/modfile04.f90
new file mode 100644 (file)
index 0000000..96c77f7
--- /dev/null
@@ -0,0 +1,51 @@
+! Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+!
+! Licensed under the Apache License, Version 2.0 (the "License");
+! you may not use this file except in compliance with the License.
+! You may obtain a copy of the License at
+!
+!     http://www.apache.org/licenses/LICENSE-2.0
+!
+! Unless required by applicable law or agreed to in writing, software
+! distributed under the License is distributed on an "AS IS" BASIS,
+! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+! See the License for the specific language governing permissions and
+! limitations under the License.
+
+! modfile with subprograms
+
+module m
+contains
+
+  pure subroutine s(x, y) bind(c)
+    logical x
+    intent(inout) y
+    intent(in) x
+  end subroutine
+
+  real function f1() result(x)
+    x = 1.0
+  end function
+
+  function f2(y)
+    complex y
+    f2 = 2.0
+  end function
+
+end
+
+!Expect: m.mod
+!module m
+!contains
+!pure subroutine s(x,y) bind(c)
+!logical,intent(in)::x
+!real,intent(inout)::y
+!end
+!function f1() result(x)
+!real::x
+!end
+!function f2(y)
+!real::f2
+!complex::y
+!end
+!end