Skip to content

Commit 8e3a42e

Browse files
committed
Testing and error reporting cleanup
Signed-off-by: Steffen Larsen <[email protected]>
1 parent 83a9875 commit 8e3a42e

10 files changed

+81
-63
lines changed

sycl/include/sycl/ext/oneapi/properties/properties.hpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ struct FindCompileTimePropertyValueType<
5858
using type = property_value<CTPropertyT, CTPropertyValueTs...>;
5959
};
6060

61+
template <typename CTPropertyT, bool HasProperty, typename PropertiesT = void>
62+
static constexpr std::enable_if_t<
63+
HasProperty,
64+
typename FindCompileTimePropertyValueType<CTPropertyT, PropertiesT>::type>
65+
get_property() {
66+
return {};
67+
}
68+
69+
template <typename CTPropertyT, bool HasProperty, typename PropertiesT = void>
70+
static constexpr std::enable_if_t<!HasProperty, void> get_property() {
71+
return;
72+
}
73+
6174
// Filters for all runtime properties with data in a tuple of properties.
6275
// NOTE: We only need storage for runtime properties with data.
6376
template <typename T> struct RuntimePropertyStorage {};
@@ -135,12 +148,21 @@ template <typename PropertiesT> class properties {
135148
}
136149

137150
template <typename PropertyT>
138-
typename std::enable_if_t<detail::IsRuntimeProperty<PropertyT>::value,
151+
typename std::enable_if_t<detail::IsRuntimeProperty<PropertyT>::value &&
152+
has_property<PropertyT>(),
139153
PropertyT>
154+
get_property() const {
155+
return std::get<PropertyT>(Storage);
156+
}
157+
158+
template <typename PropertyT>
159+
typename std::enable_if_t<detail::IsRuntimeProperty<PropertyT>::value &&
160+
!has_property<PropertyT>(),
161+
void>
140162
get_property() const {
141163
static_assert(has_property<PropertyT>(),
142164
"Property list does not contain the requested property.");
143-
return std::get<PropertyT>(Storage);
165+
return;
144166
}
145167

146168
template <typename PropertyT>
@@ -149,9 +171,8 @@ template <typename PropertiesT> class properties {
149171
* = 0) {
150172
static_assert(has_property<PropertyT>(),
151173
"Property list does not contain the requested property.");
152-
return
153-
typename detail::FindCompileTimePropertyValueType<PropertyT,
154-
PropertiesT>::type{};
174+
return detail::get_property<PropertyT, has_property<PropertyT>(),
175+
PropertiesT>();
155176
}
156177

157178
private:
Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=1 2> %t_1.err
2-
// RUN: FileCheck --check-prefix=CHECK-ERROR-1 < %t_1.err %s
3-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=2 2> %t_2.err
4-
// RUN: FileCheck --check-prefix=CHECK-ERROR-2 < %t_2.err %s
5-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=3 2> %t_3.err
6-
// RUN: FileCheck --check-prefix=CHECK-ERROR-3 < %t_3.err %s
7-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=4 2> %t_4.err
8-
// RUN: FileCheck --check-prefix=CHECK-ERROR-4 < %t_4.err %s
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
92

103
#include <CL/sycl.hpp>
114

125
#include "mock_compile_time_properties.hpp"
136

147
int main() {
15-
#if (TEST_CASE == 1)
16-
auto InvalidPropertyList = sycl::ext::oneapi::experimental::properties(1);
17-
// CHECK-ERROR-1: Unrecognized property in property list.
18-
#elif (TEST_CASE == 2)
19-
auto InvalidPropertyList = sycl::ext::oneapi::experimental::properties(
8+
// expected-error@sycl/ext/oneapi/properties/property_utils.hpp:* {{static_assert failed due to requirement 'detail::AllPropertyValues<std::tuple<int>>::value' "Unrecognized property in property list."}}
9+
// expected-error@+1 {{no viable constructor or deduction guide for deduction of template arguments of 'properties'}}
10+
auto InvalidPropertyList1 = sycl::ext::oneapi::experimental::properties(1);
11+
// expected-error@sycl/ext/oneapi/properties/property_utils.hpp:* {{static_assert failed due to requirement 'detail::AllPropertyValues<std::tuple<sycl::ext::oneapi::experimental::foo, bool>>::value' "Unrecognized property in property list."}}
12+
// expected-error@+1 {{no viable constructor or deduction guide for deduction of template arguments of 'properties'}}
13+
auto InvalidPropertyList2 = sycl::ext::oneapi::experimental::properties(
2014
sycl::ext::oneapi::experimental::foo{1}, true);
21-
// CHECK-ERROR-2: Unrecognized property in property list.
22-
#elif (TEST_CASE == 3)
23-
auto InvalidPropertyList = sycl::ext::oneapi::experimental::properties(
15+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'detail::AllUnique<std::tuple<sycl::ext::oneapi::experimental::foo, sycl::ext::oneapi::experimental::foo>>::value' "Duplicate properties in property list."}}
16+
auto InvalidPropertyList3 = sycl::ext::oneapi::experimental::properties(
2417
sycl::ext::oneapi::experimental::foo{0},
2518
sycl::ext::oneapi::experimental::foo{1});
26-
// CHECK-ERROR-3: Duplicate properties in property list.
27-
#elif (TEST_CASE == 4)
28-
auto InvalidPropertyList = sycl::ext::oneapi::experimental::properties(
19+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'detail::AllUnique<std::tuple<cl::sycl::ext::oneapi::experimental::property_value<sycl::ext::oneapi::experimental::bar_key, void>, cl::sycl::ext::oneapi::experimental::property_value<sycl::ext::oneapi::experimental::bar_key, void>>>::value' "Duplicate properties in property list."}}
20+
auto InvalidPropertyList4 = sycl::ext::oneapi::experimental::properties(
2921
sycl::ext::oneapi::experimental::bar,
3022
sycl::ext::oneapi::experimental::bar);
31-
// CHECK-ERROR-4: Duplicate properties in property list.
32-
#endif
23+
return 0;
3324
}

sycl/test/extensions/properties/properties_device_copyable.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

4-
// CUDA and HIP backends currently generates invalid binaries for this
5-
// XFAIL: cuda || hip_amd
4+
// CUDA backend currently generates invalid binaries on linux
5+
// XFAIL: cuda && linux
66

77
#include <CL/sycl.hpp>
88

@@ -60,4 +60,5 @@ int main() {
6060
PropertyList.get_property<sycl::ext::oneapi::experimental::foo_key>();
6161
});
6262
});
63+
return 0;
6364
}

sycl/test/extensions/properties/properties_equality.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>
55

@@ -13,4 +13,5 @@ int main() {
1313
sycl::ext::oneapi::experimental::bar,
1414
sycl::ext::oneapi::experimental::baz<1>));
1515
static_assert(std::is_same<P1, P2>::value);
16+
return 0;
1617
}

sycl/test/extensions/properties/properties_get_property.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ int main() {
3636
FooProp);
3737
assert(PropertyList.get_property<sycl::ext::oneapi::experimental::foo_key>()
3838
.value == FooProp.value);
39+
return 0;
3940
}
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
1-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=1 2> %t_1.err
2-
// RUN: FileCheck --check-prefix=CHECK-ERROR-1 < %t_1.err %s
3-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=2 2> %t_2.err
4-
// RUN: FileCheck --check-prefix=CHECK-ERROR-2 < %t_2.err %s
5-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=3 2> %t_3.err
6-
// RUN: FileCheck --check-prefix=CHECK-ERROR-3 < %t_3.err %s
7-
// RUN: not %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.bin -DTEST_CASE=4 2> %t_4.err
8-
// RUN: FileCheck --check-prefix=CHECK-ERROR-4 < %t_4.err %s
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
92

103
#include <CL/sycl.hpp>
114

125
#include "mock_compile_time_properties.hpp"
136

147
int main() {
158
auto EmptyPropertyList = sycl::ext::oneapi::experimental::properties();
16-
#if (TEST_CASE == 1)
17-
decltype(EmptyPropertyList)::get_property<
9+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'has_property<sycl::ext::oneapi::experimental::boo_key>()' "Property list does not contain the requested property."}}
10+
// expected-error@+1 {{variable has incomplete type 'const void'}}
11+
constexpr auto boo_val1 = decltype(EmptyPropertyList)::get_property<
1812
sycl::ext::oneapi::experimental::boo_key>();
19-
// CHECK-ERROR-1: Property list does not contain the requested property.
20-
#elif (TEST_CASE == 2)
21-
EmptyPropertyList.get_property<sycl::ext::oneapi::experimental::foo_key>();
22-
// CHECK-ERROR-2: Property list does not contain the requested property.
23-
#endif
13+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'has_property<sycl::ext::oneapi::experimental::foo>()' "Property list does not contain the requested property."}}
14+
// expected-error@+1 {{no viable conversion from 'typename std::enable_if_t<detail::IsRuntimeProperty<foo>::value && !has_property<foo>(), void>' (aka 'void') to 'sycl::ext::oneapi::experimental::foo'}}
15+
sycl::ext::oneapi::experimental::foo foo_val1 =
16+
EmptyPropertyList
17+
.get_property<sycl::ext::oneapi::experimental::foo_key>();
2418

2519
sycl::queue Q;
2620
auto PopulatedPropertyList = sycl::ext::oneapi::experimental::properties(
2721
sycl::ext::oneapi::experimental::foz{.0f, true},
2822
sycl::ext::oneapi::experimental::bar);
29-
#if (TEST_CASE == 3)
30-
decltype(PopulatedPropertyList)::get_property<
23+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'has_property<sycl::ext::oneapi::experimental::boo_key>()' "Property list does not contain the requested property."}}
24+
// expected-error@+1 {{variable has incomplete type 'const void'}}
25+
constexpr auto boo_val2 = decltype(PopulatedPropertyList)::get_property<
3126
sycl::ext::oneapi::experimental::boo_key>();
32-
// CHECK-ERROR-3: Property list does not contain the requested property.
33-
#elif (TEST_CASE == 4)
34-
PopulatedPropertyList
35-
.get_property<sycl::ext::oneapi::experimental::foo_key>();
36-
// CHECK-ERROR-4: Property list does not contain the requested property.
37-
#endif
27+
// expected-error@sycl/ext/oneapi/properties/properties.hpp:* {{static_assert failed due to requirement 'has_property<sycl::ext::oneapi::experimental::foo>()' "Property list does not contain the requested property."}}
28+
// expected-error@+1 {{no viable conversion from 'typename std::enable_if_t<detail::IsRuntimeProperty<foo>::value && !has_property<foo>(), void>' (aka 'void') to 'sycl::ext::oneapi::experimental::foo'}}
29+
sycl::ext::oneapi::experimental::foo foo_val2 =
30+
PopulatedPropertyList
31+
.get_property<sycl::ext::oneapi::experimental::foo_key>();
32+
return 0;
3833
}

sycl/test/extensions/properties/properties_has_property.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>
55

@@ -35,4 +35,6 @@ int main() {
3535
static_assert(!P3::has_property<sycl::ext::oneapi::experimental::boo_key>());
3636
static_assert(P3::has_property<sycl::ext::oneapi::experimental::foo_key>());
3737
static_assert(!P3::has_property<sycl::ext::oneapi::experimental::foz_key>());
38+
39+
return 0;
3840
}

sycl/test/extensions/properties/properties_is_property_key.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>
55

@@ -86,4 +86,6 @@ int main() {
8686
static_assert(
8787
!sycl::ext::oneapi::experimental::is_property_key_of<NotAPropertyKey,
8888
sycl::queue>::value);
89+
90+
return 0;
8991
}

sycl/test/extensions/properties/properties_is_property_list.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>
55

@@ -70,4 +70,6 @@ int main() {
7070
sycl::property_list>::value);
7171
static_assert(!sycl::ext::oneapi::experimental::is_property_list_v<
7272
sycl::property_list>);
73+
74+
return 0;
7375
}

sycl/test/extensions/properties/properties_is_property_value.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s
2+
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>
55

@@ -85,4 +85,6 @@ int main() {
8585
int, sycl::queue>::value);
8686
static_assert(!sycl::ext::oneapi::experimental::is_property_value_of<
8787
NotAPropertyKey, sycl::queue>::value);
88+
89+
return 0;
8890
}

0 commit comments

Comments
 (0)