diff --git a/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_arg.hpp b/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_arg.hpp index 10c3a5c36ba39..fcc1e6e8d8cad 100644 --- a/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_arg.hpp +++ b/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_arg.hpp @@ -76,6 +76,9 @@ __SYCL_TYPE(annotated_arg) annotated_arg> { public: static_assert(is_property_list::value, "Property list is invalid."); + static_assert( + validate_annotated_type>::value, + "The property list contains invalid property."); annotated_arg() noexcept = default; annotated_arg(const annotated_arg &) = default; @@ -178,8 +181,9 @@ __SYCL_TYPE(annotated_arg) annotated_arg> { static_assert(is_device_copyable_v, "Type T must be device copyable."); static_assert(is_property_list::value, "Property list is invalid."); - static_assert(check_property_list::value, - "The property list contains invalid property."); + static_assert( + validate_annotated_type>::value, + "The property list contains invalid property."); annotated_arg() noexcept = default; annotated_arg(const annotated_arg &) = default; diff --git a/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_ptr.hpp b/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_ptr.hpp index 1998d18e11b8a..70fec047c0ac2 100644 --- a/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_ptr.hpp +++ b/sycl/include/sycl/ext/oneapi/annotated_arg/annotated_ptr.hpp @@ -121,6 +121,9 @@ __SYCL_TYPE(annotated_ptr) annotated_ptr> { public: static_assert(is_property_list::value, "Property list is invalid."); + static_assert( + validate_annotated_type>::value, + "The property list contains invalid property."); annotated_ptr() noexcept = default; annotated_ptr(const annotated_ptr &) = default; diff --git a/sycl/include/sycl/ext/oneapi/annotated_arg/properties.hpp b/sycl/include/sycl/ext/oneapi/annotated_arg/properties.hpp index 277859a4f71c0..482e201a95655 100644 --- a/sycl/include/sycl/ext/oneapi/annotated_arg/properties.hpp +++ b/sycl/include/sycl/ext/oneapi/annotated_arg/properties.hpp @@ -327,15 +327,60 @@ struct is_valid_property : std::true_type {}; template struct is_valid_property : std::true_type {}; +// Check if a given property is supported for annotated_arg +// e.g. `alignment` is not supported for annotated_arg +template +using is_property_value_of_annotated_arg = + is_property_value_of>; + +// Check if a given property is supported for annotated_ptr +template +using is_property_value_of_annotated_ptr = + is_property_value_of>; + +// Validate anntoated_arg/annotated_ptr +template struct validate_annotated_type : std::false_type {}; + +// Partial specializations for validating annotated_arg template -struct check_property_list : std::true_type {}; +struct validate_annotated_type>> + : std::true_type {}; template -struct check_property_list - : std::conditional_t::value, - check_property_list, std::false_type> { - static_assert(is_valid_property::value, - "Property is invalid for the given type."); +struct validate_annotated_type< + annotated_arg>> + : std::conditional_t::value && + is_property_value_of_annotated_arg::value, + validate_annotated_type< + annotated_arg>>, + std::false_type> { + static_assert( + is_valid_property::value, + "Property is invalid for the underlying type of annotated_arg."); + static_assert(is_property_value_of_annotated_arg::value, + "Property is not supported for annotated_arg."); +}; + +// Partial specializations for validating annotated_arg +template +struct validate_annotated_type>> + : std::true_type {}; + +template +struct validate_annotated_type< + annotated_ptr>> + : std::conditional_t::value && + is_property_value_of_annotated_ptr::value, + validate_annotated_type< + annotated_ptr>>, + std::false_type> { + static_assert( + is_valid_property::value, + "Property is invalid for the underlying type of annotated_ptr."); + static_assert(is_property_value_of_annotated_ptr::value, + "Property is not supported for annotated_ptr."); }; //===----------------------------------------------------------------------===// @@ -354,6 +399,10 @@ template struct is_property_key_of> : std::true_type {}; +template +struct is_valid_property> + : std::bool_constant::value> {}; + namespace detail { template <> struct PropertyToKind {