Skip to content

Commit ce69a60

Browse files
authored
Skip contiguous check when ignore_tkr(c) is used (#138762)
The point of ignore_tkr(c) is to ignore both contiguous warnings and errors for arguments of all attribute types.
1 parent 52e5889 commit ce69a60

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
10161016
}
10171017
}
10181018
if (dummyDataAttr == common::CUDADataAttr::Device &&
1019-
(dummyIsAssumedShape || dummyIsAssumedRank)) {
1019+
(dummyIsAssumedShape || dummyIsAssumedRank) &&
1020+
!dummy.ignoreTKR.test(common::IgnoreTKR::Contiguous)) {
10201021
if (auto contig{evaluate::IsContiguous(actual, foldingContext,
10211022
/*namedConstantSectionsAreContiguous=*/true,
10221023
/*firstDimensionStride1=*/true)}) {

flang/test/Semantics/cuf20.cuf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
3+
! Test case 1: Device arrays with ignore_tkr(c)
4+
subroutine test_device_arrays()
5+
interface bar
6+
subroutine bar1(a)
7+
!dir$ ignore_tkr(c) a
8+
real :: a(..)
9+
!@cuf attributes(device) :: a
10+
end subroutine
11+
end interface
12+
13+
integer :: n = 10, k = 2
14+
real, device :: a(10), b(10), c(10)
15+
16+
call bar(a(1:n)) ! Should not warn about contiguity
17+
call bar(b(1:n:k)) ! Should not warn about contiguity
18+
call bar(c(1:n:2)) ! Should not warn about contiguity
19+
end subroutine
20+
21+
! Test case 2: Managed arrays with ignore_tkr(c)
22+
subroutine test_managed_arrays()
23+
interface bar
24+
subroutine bar1(a)
25+
!dir$ ignore_tkr(c) a
26+
real :: a(..)
27+
!@cuf attributes(device) :: a
28+
end subroutine
29+
end interface
30+
31+
integer :: n = 10, k = 2
32+
real, managed :: a(10), b(10), c(10)
33+
34+
call bar(a(1:n)) ! Should not warn about contiguity
35+
call bar(b(1:n:k)) ! Should not warn about contiguity
36+
call bar(c(1:n:2)) ! Should not warn about contiguity
37+
end subroutine
38+
39+
program main
40+
call test_device_arrays()
41+
call test_managed_arrays()
42+
end program

0 commit comments

Comments
 (0)