Skip to content

Commit

Permalink
Merge pull request #857 from AlexeySachkov/private/asachkov/drop-erro…
Browse files Browse the repository at this point in the history
…r-category-for

[NFC] Drop code related to `error_category_for`
  • Loading branch information
tomdeakin authored Jan 25, 2024
2 parents 1e7e820 + 094d135 commit f843993
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions util/sycl_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@

#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE 1
#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY 0
#define SYCL_CTS_SUPPORT_HAS_ERRC_FOR 0
#define SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR 0
#define SYCL_CTS_SUPPORT_HAS_MAKE_ERROR_CODE 0

#elif SYCL_CTS_COMPILING_WITH_DPCPP
// Feature flags for DPC++

#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE 1
#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY 1
#define SYCL_CTS_SUPPORT_HAS_ERRC_FOR 1
#define SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR 0
#define SYCL_CTS_SUPPORT_HAS_MAKE_ERROR_CODE 0

#else

#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE 1
#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY 1
#define SYCL_CTS_SUPPORT_HAS_ERRC_FOR 1
#define SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR 1
#define SYCL_CTS_SUPPORT_HAS_MAKE_ERROR_CODE 1

#endif
Expand Down Expand Up @@ -131,49 +125,6 @@ struct matcher_equals_exception
};
#endif // SYCL_CTS_SUPPORT_HAS_ERRC_ENUM

/**
* Matcher for backend-specific category and error codes
*/
template <sycl::backend Backend, typename CodeT>
class matcher_equals_exception_for
: public Catch::Matchers::MatcherGenericBase {
public:
matcher_equals_exception_for(const CodeT& code_value)
: m_code_value(code_value) {}

bool match(const sycl::exception& other) const {

#if (SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE == 0) || \
(SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY == 0) || \
(SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR == 0)
// There should be no compilation failures, but every CHECK_THROWS_MATCHES
// should fail with this matcher
return false;
#else
// Error code is validated by value, with no semantic match
const auto& expected_category = sycl::error_category_for<Backend>();
return (other.category() == expected_category) &&
(other.code().value() == m_code_value);
#endif
}

std::string describe() const override {
std::ostringstream result;
result << "has code value " << to_integral(m_code_value);

#if (SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR == 0)
result << " for backend-specific category (not supported)";
#else
const auto& expected_category = sycl::error_category_for<Backend>();
result << " for backend-specific category '" << expected_category().name();
result << "'";
#endif
return result.str();
}

private:
const CodeT& m_code_value;
};
} // namespace detail

/**
Expand Down Expand Up @@ -202,22 +153,6 @@ inline auto equals_exception(const sycl::errc& code) {
}
#endif // SYCL_CTS_SUPPORT_HAS_ERRC_ENUM == 1

/**
* Provides matcher for backend-specific category and error codes
*
* Usage example:
* CHECK_THROWS_MATCHES(action(), sycl::exception,
* equals_exception_for<sycl::backend::opencl>(CL_INVALID_PROGRAM));
*/
template <sycl::backend Backend, typename CodeT>
inline auto equals_exception_for(const CodeT& code) {
#if SYCL_CTS_SUPPORT_HAS_ERRC_FOR == 1
static_assert(std::is_same_v<CodeT, sycl::errc_for<Backend>> ||
std::is_same_v<CodeT, int>);
#endif
return detail::matcher_equals_exception_for<Backend, CodeT>(code);
}

} // namespace sycl_cts::util

/**
Expand Down

0 comments on commit f843993

Please sign in to comment.