Skip to content

[flang][cuda] Remove restriction on device subprogram #89677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,10 +1436,6 @@ void CheckHelper::CheckSubprogram(
}
if (cudaAttrs && *cudaAttrs != common::CUDASubprogramAttrs::Host) {
// CUDA device subprogram checks
if (symbol.attrs().HasAny({Attr::RECURSIVE, Attr::PURE, Attr::ELEMENTAL})) {
messages_.Say(symbol.name(),
"A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL"_err_en_US);
}
if (ClassifyProcedure(symbol) == ProcedureDefinitionClass::Internal) {
messages_.Say(symbol.name(),
"A device subprogram may not be an internal subprogram"_err_en_US);
Expand Down
18 changes: 6 additions & 12 deletions flang/test/Semantics/cuf02.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ module m
end
end interface
contains
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
recursive attributes(device) subroutine s1
recursive attributes(device) subroutine s1 ! ok
end
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
pure attributes(device) subroutine s2
pure attributes(device) subroutine s2 ! ok
end
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
elemental attributes(device) subroutine s3
elemental attributes(device) subroutine s3 ! ok
end
subroutine s4
contains
Expand All @@ -32,14 +29,11 @@ module m
!ERROR: A function may not have ATTRIBUTES(GLOBAL) or ATTRIBUTES(GRID_GLOBAL)
attributes(global) real function f1
end
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
recursive attributes(global) subroutine s7
recursive attributes(global) subroutine s7 ! ok
end
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
pure attributes(global) subroutine s8
pure attributes(global) subroutine s8 ! ok
end
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
elemental attributes(global) subroutine s9
elemental attributes(global) subroutine s9 ! ok
end
end

Expand Down