@@ -8953,6 +8953,18 @@ void ResolveNamesVisitor::FinishSpecificationPart(
89538953 misparsedStmtFuncFound_ = false ;
89548954 funcResultStack ().CompleteFunctionResultType ();
89558955 CheckImports ();
8956+ bool inDeviceSubprogram = false ;
8957+ if (auto *subp{currScope ().symbol ()
8958+ ? currScope ().symbol ()->detailsIf <SubprogramDetails>()
8959+ : nullptr }) {
8960+ if (auto attrs{subp->cudaSubprogramAttrs ()}) {
8961+ if (*attrs != common::CUDASubprogramAttrs::Device ||
8962+ *attrs != common::CUDASubprogramAttrs::Global ||
8963+ *attrs != common::CUDASubprogramAttrs::Grid_Global) {
8964+ inDeviceSubprogram = true ;
8965+ }
8966+ }
8967+ }
89568968 for (auto &pair : currScope ()) {
89578969 auto &symbol{*pair.second };
89588970 if (inInterfaceBlock ()) {
@@ -8961,6 +8973,13 @@ void ResolveNamesVisitor::FinishSpecificationPart(
89618973 if (NeedsExplicitType (symbol)) {
89628974 ApplyImplicitRules (symbol);
89638975 }
8976+ if (inDeviceSubprogram && IsDummy (symbol) && symbol.has <ObjectEntityDetails>()) {
8977+ auto *dummy{symbol.detailsIf <ObjectEntityDetails>()};
8978+ if (!dummy->cudaDataAttr ()) {
8979+ // Implicitly set device attribute if none is set in device context.
8980+ dummy->set_cudaDataAttr (common::CUDADataAttr::Device);
8981+ }
8982+ }
89648983 if (IsDummy (symbol) && isImplicitNoneType () &&
89658984 symbol.test (Symbol::Flag::Implicit) && !context ().HasError (symbol)) {
89668985 Say (symbol.name (),
0 commit comments