[flang] Support kind/index lookup inside of EQUIVALENCE (#170056)
Turn off "in EQUIVALENCE" check for processing of array subscripts, since subscripts themselves are not part of the EQUIVALENCE. Fixes #169590
This commit is contained in:
parent
00c8e615e3
commit
21d006c482
2 changed files with 29 additions and 0 deletions
|
|
@ -2153,6 +2153,8 @@ public:
|
|||
void Post(const parser::AssignedGotoStmt &);
|
||||
void Post(const parser::CompilerDirective &);
|
||||
|
||||
bool Pre(const parser::SectionSubscript &);
|
||||
|
||||
// These nodes should never be reached: they are handled in ProgramUnit
|
||||
bool Pre(const parser::MainProgram &) {
|
||||
llvm_unreachable("This node is handled in ProgramUnit");
|
||||
|
|
@ -10218,6 +10220,14 @@ template <typename A> std::set<SourceName> GetUses(const A &x) {
|
|||
return uses;
|
||||
}
|
||||
|
||||
bool ResolveNamesVisitor::Pre(const parser::SectionSubscript &x) {
|
||||
// Turn off "in EQUIVALENCE" check for array indexing, because
|
||||
// the indices themselves are not part of the EQUIVALENCE.
|
||||
auto restorer{common::ScopedSet(inEquivalenceStmt_, false)};
|
||||
Walk(x.u);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ResolveNamesVisitor::Pre(const parser::Program &x) {
|
||||
if (Scope * hermetic{context().currentHermeticModuleFileScope()}) {
|
||||
// Processing either the dependent modules or first module of a
|
||||
|
|
|
|||
19
flang/test/Semantics/equiv-kind.f90
Normal file
19
flang/test/Semantics/equiv-kind.f90
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
|
||||
module equiv_kind_m
|
||||
implicit none
|
||||
integer, parameter :: knd = kind(42)
|
||||
integer, parameter :: dim_2 = 1_knd
|
||||
integer, parameter :: n = 3_knd
|
||||
integer, parameter :: i_start = 1_knd
|
||||
contains
|
||||
subroutine test()
|
||||
integer(knd) :: a(n),b(n,n)
|
||||
character(len=5) :: small_ch
|
||||
character(len=20) :: large_ch
|
||||
|
||||
equivalence (a(1_knd),b(1_knd,dim_2))
|
||||
!CHECK: EQUIVALENCE (a(1_4), b(1_4,1_4))
|
||||
equivalence (small_ch, large_ch(i_start:5_knd))
|
||||
!CHECK: EQUIVALENCE (small_ch, large_ch(1_4:5_4))
|
||||
end subroutine test
|
||||
end module equiv_kind_m
|
||||
Loading…
Reference in a new issue