Skip to content

Commit 39a9073

Browse files
authored
[flang][cuda] Downgrade allocate pinned error to a warning (llvm#121589)
To be in accordance with the reference compiler.
1 parent a4e4758 commit 39a9073

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

flang/lib/Semantics/check-allocate.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,11 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
616616
}
617617
if (allocateInfo_.gotPinned) {
618618
std::optional<common::CUDADataAttr> cudaAttr{GetCUDADataAttr(ultimate_)};
619-
if (!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) {
619+
if ((!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) &&
620+
context.languageFeatures().ShouldWarn(
621+
common::UsageWarning::CUDAUsage)) {
620622
context.Say(name_.source,
621-
"Object in ALLOCATE must have PINNED attribute when PINNED option is specified"_err_en_US);
623+
"Object in ALLOCATE should have PINNED attribute when PINNED option is specified"_warn_en_US);
622624
}
623625
}
624626
if (allocateInfo_.gotStream) {

flang/test/Semantics/cuf07.cuf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module m
2828
integer, allocatable, device :: ia(:)
2929
logical :: plog
3030

31-
!ERROR: Object in ALLOCATE must have PINNED attribute when PINNED option is specified
31+
!WARNING: Object in ALLOCATE should have PINNED attribute when PINNED option is specified
3232
allocate(ia(100), pinned = plog)
3333
end subroutine
3434

0 commit comments

Comments
 (0)