@@ -8953,6 +8953,18 @@ void ResolveNamesVisitor::FinishSpecificationPart(
8953
8953
misparsedStmtFuncFound_ = false ;
8954
8954
funcResultStack ().CompleteFunctionResultType ();
8955
8955
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
+ }
8956
8968
for (auto &pair : currScope ()) {
8957
8969
auto &symbol{*pair.second };
8958
8970
if (inInterfaceBlock ()) {
@@ -8961,6 +8973,14 @@ void ResolveNamesVisitor::FinishSpecificationPart(
8961
8973
if (NeedsExplicitType (symbol)) {
8962
8974
ApplyImplicitRules (symbol);
8963
8975
}
8976
+ if (inDeviceSubprogram && IsDummy (symbol) &&
8977
+ symbol.has <ObjectEntityDetails>()) {
8978
+ auto *dummy{symbol.detailsIf <ObjectEntityDetails>()};
8979
+ if (!dummy->cudaDataAttr ()) {
8980
+ // Implicitly set device attribute if none is set in device context.
8981
+ dummy->set_cudaDataAttr (common::CUDADataAttr::Device);
8982
+ }
8983
+ }
8964
8984
if (IsDummy (symbol) && isImplicitNoneType () &&
8965
8985
symbol.test (Symbol::Flag::Implicit) && !context ().HasError (symbol)) {
8966
8986
Say (symbol.name (),
0 commit comments