diff --git a/flang/lib/Semantics/definable.cpp b/flang/lib/Semantics/definable.cpp index 2c57efbb40cd1..5c3fa905d6072 100644 --- a/flang/lib/Semantics/definable.cpp +++ b/flang/lib/Semantics/definable.cpp @@ -160,9 +160,10 @@ static std::optional WhyNotDefinableBase(parser::CharBlock at, "'%s' is a host-associated allocatable and is not definable in a device subprogram"_err_en_US, original); } else if (*cudaDataAttr != common::CUDADataAttr::Device && - *cudaDataAttr != common::CUDADataAttr::Managed) { + *cudaDataAttr != common::CUDADataAttr::Managed && + *cudaDataAttr != common::CUDADataAttr::Shared) { return BlameSymbol(at, - "'%s' is not device or managed data and is not definable in a device subprogram"_err_en_US, + "'%s' is not device or managed or shared data and is not definable in a device subprogram"_err_en_US, original); } } else if (!isOwnedByDeviceCode) { diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf index 4260d7edd626f..41bfbb7678136 100644 --- a/flang/test/Semantics/cuf03.cuf +++ b/flang/test/Semantics/cuf03.cuf @@ -62,4 +62,11 @@ module m !ERROR: Object 'rc' with ATTRIBUTES(CONSTANT) may not be declared in a host subprogram real, constant :: rc end subroutine + + attributes(global) subroutine devsubr2() + real, shared :: rs + + rs = 1 ! ok + end subroutine + end module