Skip to content

Commit 9b3465e

Browse files
[SYCL] Add compile-only sycl::span tests (#5056)
span declaration tests only require compilation, should be routinely checked by check-sycl, instead of llvm-test-suite. Signed-off-by: Chris Perkins <[email protected]>
1 parent 41c15ce commit 9b3465e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

sycl/test/basic_tests/span.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %clangxx -fsycl -c %s
2+
3+
//==--------------- span.cpp - SYCL span test ------------------------------==//
4+
//
5+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6+
// See https://llvm.org/LICENSE.txt for license information.
7+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
//
9+
//===----------------------------------------------------------------------===//
10+
11+
#include <CL/sycl.hpp>
12+
13+
int main() {
14+
// test the various span declarations, especially unspecialized ones.
15+
// should compile
16+
int arr[]{1, 2, 3, 4};
17+
const int constArr[]{8, 7, 6};
18+
std::vector<int> vec(4);
19+
20+
// unspecialized
21+
sycl::span fromArray{arr};
22+
sycl::span fromConstArray{constArr};
23+
sycl::span fromVec{vec};
24+
25+
// partly specialized
26+
sycl::span<int> fromIntArray{arr};
27+
sycl::span<const int> fromIntConstArray{constArr};
28+
sycl::span<int> fromIntVec{vec};
29+
30+
// fully specialized
31+
// TODO: fix fully specialized span from array declaration support
32+
// sycl::span<int,4> fullSpecArray{arr};
33+
// sycl::span<const int,3> fullSpecConstArray{constArr};
34+
sycl::span<int, 4> fullSpecVecArray{vec};
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)