@@ -1643,9 +1643,28 @@ bool OmpVisitor::Pre(const parser::OpenMPDeclareMapperConstruct &x) {
16431643
16441644bool 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
0 commit comments