@@ -1824,21 +1824,24 @@ bool OmpVisitor::Pre(const parser::OmpMapClause &x) {
18241824 // TODO: Do we need a specific flag or type here, to distinghuish against
18251825 // other ConstructName things? Leaving this for the full implementation
18261826 // of mapper lowering.
1827- auto *misc{symbol->detailsIf <MiscDetails>()};
1827+ const Symbol &ultimate{symbol->GetUltimate ()};
1828+ auto *misc{const_cast <Symbol &>(ultimate).detailsIf <MiscDetails>()};
18281829 if (!misc || misc->kind () != MiscDetails::Kind::ConstructName)
18291830 context ().Say (mapper->v .source ,
18301831 " Name '%s' should be a mapper name" _err_en_US, mapper->v .source );
18311832 else
18321833 mapper->v .symbol = symbol;
18331834 } else {
1834- mapper->v .symbol =
1835- &MakeSymbol (mapper->v , MiscDetails{MiscDetails::Kind::ConstructName});
1836- // TODO: When completing the implementation, we probably want to error if
1837- // the symbol is not declared, but right now, testing that the TODO for
1838- // OmpMapClause happens is obscured by the TODO for declare mapper, so
1839- // leaving this out. Remove the above line once the declare mapper is
1840- // implemented. context().Say(mapper->v.source, "'%s' not
1841- // declared"_err_en_US, mapper->v.source);
1835+ // Allow the special 'default' mapper identifier without prior
1836+ // declaration so lowering can recognize and handle it. Emit an
1837+ // error for any other missing mapper identifier.
1838+ if (mapper->v .source .ToString () == " default" ) {
1839+ mapper->v .symbol = &MakeSymbol (
1840+ mapper->v , MiscDetails{MiscDetails::Kind::ConstructName});
1841+ } else {
1842+ context ().Say (
1843+ mapper->v .source , " '%s' not declared" _err_en_US, mapper->v .source );
1844+ }
18421845 }
18431846 }
18441847 return true ;
@@ -3614,10 +3617,18 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
36143617 rename.u );
36153618 }
36163619 for (const auto &[name, symbol] : *useModuleScope_) {
3620+ // Default USE imports public names, excluding intrinsic-only and most
3621+ // miscellaneous details. However, allow OpenMP mapper identifiers,
3622+ // which are currently represented with MiscDetails::ConstructName.
3623+ bool isMapper{false };
3624+ if (const auto *misc{symbol->detailsIf <MiscDetails>()}) {
3625+ isMapper = misc->kind () == MiscDetails::Kind::ConstructName;
3626+ }
36173627 if (symbol->attrs ().test (Attr::PUBLIC) && !IsUseRenamed (symbol->name ()) &&
36183628 (!symbol->implicitAttrs ().test (Attr::INTRINSIC) ||
36193629 symbol->has <UseDetails>()) &&
3620- !symbol->has <MiscDetails>() && useNames.count (name) == 0 ) {
3630+ (!symbol->has <MiscDetails>() || isMapper) &&
3631+ useNames.count (name) == 0 ) {
36213632 SourceName location{x.moduleName .source };
36223633 if (auto *localSymbol{FindInScope (name)}) {
36233634 DoAddUse (location, localSymbol->name (), *localSymbol, *symbol);
0 commit comments