Skip to content

Commit 49cb6db

Browse files
authored
[flang][cuda] Remove restriction on device subprogram (llvm#89677)
Newer version allow `pure`, `elemental` and `recursive` on device subprogram.
1 parent abfb491 commit 49cb6db

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,10 +1436,6 @@ void CheckHelper::CheckSubprogram(
14361436
}
14371437
if (cudaAttrs && *cudaAttrs != common::CUDASubprogramAttrs::Host) {
14381438
// CUDA device subprogram checks
1439-
if (symbol.attrs().HasAny({Attr::RECURSIVE, Attr::PURE, Attr::ELEMENTAL})) {
1440-
messages_.Say(symbol.name(),
1441-
"A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL"_err_en_US);
1442-
}
14431439
if (ClassifyProcedure(symbol) == ProcedureDefinitionClass::Internal) {
14441440
messages_.Say(symbol.name(),
14451441
"A device subprogram may not be an internal subprogram"_err_en_US);

flang/test/Semantics/cuf02.cuf

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ module m
55
end
66
end interface
77
contains
8-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
9-
recursive attributes(device) subroutine s1
8+
recursive attributes(device) subroutine s1 ! ok
109
end
11-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
12-
pure attributes(device) subroutine s2
10+
pure attributes(device) subroutine s2 ! ok
1311
end
14-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
15-
elemental attributes(device) subroutine s3
12+
elemental attributes(device) subroutine s3 ! ok
1613
end
1714
subroutine s4
1815
contains
@@ -32,14 +29,11 @@ module m
3229
!ERROR: A function may not have ATTRIBUTES(GLOBAL) or ATTRIBUTES(GRID_GLOBAL)
3330
attributes(global) real function f1
3431
end
35-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
36-
recursive attributes(global) subroutine s7
32+
recursive attributes(global) subroutine s7 ! ok
3733
end
38-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
39-
pure attributes(global) subroutine s8
34+
pure attributes(global) subroutine s8 ! ok
4035
end
41-
!ERROR: A device subprogram may not be RECURSIVE, PURE, or ELEMENTAL
42-
elemental attributes(global) subroutine s9
36+
elemental attributes(global) subroutine s9 ! ok
4337
end
4438
end
4539

0 commit comments

Comments
 (0)