forked from OSchip/llvm-project
[flang] Write function result to .mod file after dummy args
The function result can depend on the declaration of the dummy arguments so it should be written to the .mod file after them. For example: ``` function f(x) integer :: x(:) integer :: f(size(x)) end ``` Original-commit: flang-compiler/f18@f6c8c58c24 Reviewed-on: https://github.com/flang-compiler/f18/pull/650 Tree-same-pre-rewrite: false
This commit is contained in:
parent
65de6787e2
commit
2bc9a1ebed
|
@ -786,12 +786,12 @@ static std::string ModFilePath(const std::string &dir, const SourceName &name,
|
|||
void SubprogramSymbolCollector::Collect() {
|
||||
const auto &details{symbol_.get<SubprogramDetails>()};
|
||||
isInterface_ = details.isInterface();
|
||||
if (details.isFunction()) {
|
||||
DoSymbol(details.result());
|
||||
}
|
||||
for (const Symbol *dummyArg : details.dummyArgs()) {
|
||||
DoSymbol(DEREF(dummyArg));
|
||||
}
|
||||
if (details.isFunction()) {
|
||||
DoSymbol(details.result());
|
||||
}
|
||||
for (const auto &pair : scope_) {
|
||||
const Symbol *symbol{pair.second};
|
||||
if (const auto *useDetails{symbol->detailsIf<UseDetails>()}) {
|
||||
|
|
|
@ -211,6 +211,7 @@ set(MODFILE_TESTS
|
|||
modfile27.f90
|
||||
modfile28.f90
|
||||
modfile29.f90
|
||||
modfile30.f90
|
||||
)
|
||||
|
||||
set(LABEL_TESTS
|
||||
|
|
|
@ -65,8 +65,8 @@ end
|
|||
!real(4)::x
|
||||
!end
|
||||
!function f2(y)
|
||||
!real(4)::f2
|
||||
!complex(4)::y
|
||||
!real(4)::f2
|
||||
!end
|
||||
!end
|
||||
|
||||
|
@ -75,12 +75,12 @@ end
|
|||
!contains
|
||||
!function f3(x)
|
||||
! use m1,only:t
|
||||
! type(t)::f3
|
||||
! type::t2(b)
|
||||
! integer(4),kind::b=2_4
|
||||
! integer(4)::y
|
||||
! end type
|
||||
! type(t2(b=2_4))::x
|
||||
! type(t)::f3
|
||||
!end
|
||||
!function f4() result(x)
|
||||
!complex(4)::x
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
! Copyright (c) 2018-2019, 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.
|
||||
|
@ -28,8 +28,8 @@ end
|
|||
!module m
|
||||
! interface
|
||||
! function f(x)
|
||||
! integer(4)::f
|
||||
! real(4)::x
|
||||
! integer(4)::f
|
||||
! end
|
||||
! end interface
|
||||
! interface
|
||||
|
|
|
@ -51,16 +51,16 @@ end
|
|||
! end interface
|
||||
! interface
|
||||
! function s1(x,y)
|
||||
! real(4)::s1
|
||||
! real(4)::x
|
||||
! real(4)::y
|
||||
! real(4)::s1
|
||||
! end
|
||||
! end interface
|
||||
! interface
|
||||
! function s2(x,y)
|
||||
! complex(4)::s2
|
||||
! complex(4)::x
|
||||
! complex(4)::y
|
||||
! complex(4)::s2
|
||||
! end
|
||||
! end interface
|
||||
! interface operator(+)
|
||||
|
@ -81,14 +81,14 @@ end
|
|||
! end interface
|
||||
!contains
|
||||
! function s3(x,y)
|
||||
! logical(4)::s3
|
||||
! logical(4)::x
|
||||
! logical(4)::y
|
||||
! logical(4)::s3
|
||||
! end
|
||||
! function s4(x,y)
|
||||
! integer(4)::s4
|
||||
! integer(4)::x
|
||||
! integer(4)::y
|
||||
! integer(4)::s4
|
||||
! end
|
||||
!end
|
||||
|
||||
|
@ -158,11 +158,11 @@ end
|
|||
! subroutine s1(f)
|
||||
! interface
|
||||
! function f(x)
|
||||
! real(4)::f
|
||||
! interface
|
||||
! subroutine x()
|
||||
! end
|
||||
! end interface
|
||||
! real(4)::f
|
||||
! end
|
||||
! end interface
|
||||
! end
|
||||
|
@ -194,8 +194,8 @@ end
|
|||
! end interface
|
||||
! interface
|
||||
! function f(x)
|
||||
! integer(4)::f
|
||||
! real(4)::x
|
||||
! integer(4)::f
|
||||
! end
|
||||
! end interface
|
||||
!end
|
||||
|
@ -231,8 +231,8 @@ end
|
|||
! end interface
|
||||
! interface
|
||||
! function f(x)
|
||||
! integer(4)::f
|
||||
! real(4)::x
|
||||
! integer(4)::f
|
||||
! end
|
||||
! end interface
|
||||
!end
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
! Copyright (c) 2019, 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.
|
||||
|
||||
! Verify miscellaneous bugs
|
||||
|
||||
! The function result must be declared after the dummy arguments
|
||||
module m1
|
||||
contains
|
||||
function f1(x) result(y)
|
||||
integer :: x(:)
|
||||
integer :: y(size(x))
|
||||
end
|
||||
function f2(x)
|
||||
integer :: x(:)
|
||||
integer :: f2(size(x))
|
||||
end
|
||||
end
|
||||
|
||||
!Expect: m1.mod
|
||||
!module m1
|
||||
!contains
|
||||
! function f1(x) result(y)
|
||||
! integer(4)::x(:)
|
||||
! integer(4)::y(1_8:1_8*size(x,dim=1))
|
||||
! end
|
||||
! function f2(x)
|
||||
! integer(4)::x(:)
|
||||
! integer(4)::f2(1_8:1_8*size(x,dim=1))
|
||||
! end
|
||||
!end
|
Loading…
Reference in New Issue