Skip to content

Commit 7d162af

Browse files
Add FindSymbol and update tests
1 parent 042adcf commit 7d162af

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,9 +1643,28 @@ bool OmpVisitor::Pre(const parser::OpenMPDeclareMapperConstruct &x) {
16431643

16441644
bool OmpVisitor::Pre(const parser::OmpMapClause &x) {
16451645
const auto &mid{std::get<parser::OmpMapperIdentifier>(x.t)};
1646-
if (const auto &mapperName{mid.v})
1647-
mapperName->symbol =
1648-
&MakeSymbol(*mapperName, MiscDetails{MiscDetails::Kind::ConstructName});
1646+
if (const auto &mapperName{mid.v}) {
1647+
if (const auto symbol = FindSymbol(currScope(), *mapperName)) {
1648+
// TODO: Do we need a specific flag or type here, to distinghuish against
1649+
// other ConstructName things? Leaving this for the full implementation
1650+
// of mapper lowering.
1651+
auto *misc{symbol->detailsIf<MiscDetails>()};
1652+
if (!misc || misc->kind() != MiscDetails::Kind::ConstructName)
1653+
context().Say(mapperName->source,
1654+
"Name '%s' should be a mapper name"_err_en_US, mapperName->source);
1655+
else
1656+
mapperName->symbol = symbol;
1657+
} else {
1658+
mapperName->symbol = &MakeSymbol(
1659+
*mapperName, MiscDetails{MiscDetails::Kind::ConstructName});
1660+
// TODO: When completing the implementation, we probably want to error if
1661+
// the symbol is not declared, but right now, testing that the TODO for
1662+
// OmpMapclause happens is obscured by the TODO for declare mapper, so
1663+
// leaving this out. Remove the above line once the declare mapper is
1664+
// implemented. context().Say(mapperName->source, "'%s' not
1665+
// declared"_err_en_US, mapperName->source);
1666+
}
1667+
}
16491668
return true;
16501669
}
16511670

flang/test/Lower/OpenMP/Todo/map-mapper.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
program p
33
integer, parameter :: n = 256
44
real(8) :: a(256)
5+
!! TODO: Add declare mapper, when it works to lower this construct
6+
!!type t1
7+
!! integer :: x
8+
!!end type t1
9+
!!!$omp declare mapper(xx : t1 :: nn) map(nn, nn%x)
510
!$omp target map(mapper(xx), from:a)
611
!CHECK: not yet implemented: OmpMapClause(MAPPER(...))
712
do i=1,n

flang/test/Semantics/OpenMP/map-clause.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ subroutine sb(arr)
3333
c = 2
3434
!$omp end target
3535
end subroutine
36+
37+
subroutine sb1
38+
integer :: xx
39+
integer :: a
40+
!ERROR: Name 'xx' should be a mapper name
41+
!$omp target map(mapper(xx), from:a)
42+
!$omp end target
43+
end subroutine sb1

0 commit comments

Comments
 (0)