Skip to content

Commit

Permalink
CI fixes (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Feb 16, 2024
1 parent 8f3b819 commit 9b90f2f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: gcc-13
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
- toolset: gcc-12 # Do not remove! It is the only toolset that tests misc/strip_boost_namespace.sh
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
Expand All @@ -41,10 +44,7 @@ jobs:
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-9"
- toolset: clang-14
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
- toolset: clang-13
- toolset: clang-15
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
# - toolset: clang
Expand Down
13 changes: 9 additions & 4 deletions example/quick_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,23 @@ void test_examples() {
//]
}

#if BOOST_PFR_CORE_NAME_ENABLED && BOOST_PFR_USE_CPP17
// Disabling for MSVC as it gives a hard error on using local types:
//
// error C7631:
// 'boost::pfr::detail::do_not_use_PFR_with_local_types<test_examples::sample>':
// variable with internal linkage declared but not defined
#if BOOST_PFR_CORE_NAME_ENABLED && BOOST_PFR_USE_CPP17 && !defined(_MSC_VER)
{
//[pfr_quick_examples_get_name
// Get name of field by index

struct sample {
int f1;
long f2;
int f_int;
long f_long;
};

std::cout << boost::pfr::get_name<0, sample>()
<< boost::pfr::get_name<1, sample>(); // Outputs: f1 f2
<< boost::pfr::get_name<1, sample>(); // Outputs: f_int f_long
//]
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/boost/pfr/detail/fake_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct wrapper {
// This variable servers as a link-time assert.
// If linker requires it, then `fake_object()` is used at runtime.
template <class T>
extern const wrapper<T> report_if_you_see_link_error_with_this_object;
extern const wrapper<T> do_not_use_PFR_with_local_types;

// For returning non default constructible types, it's exclusively used in member name retrieval.
//
Expand All @@ -43,7 +43,7 @@ extern const wrapper<T> report_if_you_see_link_error_with_this_object;
// with the former standards.
template <class T>
constexpr const T& fake_object() noexcept {
return report_if_you_see_link_error_with_this_object<T>.value;
return do_not_use_PFR_with_local_types<T>.value;
}

}}} // namespace boost::pfr::detail
Expand Down
14 changes: 14 additions & 0 deletions test/core_name/run/fields_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ void test_get_name_by_id() {
}

void test_get_name_by_id_without_linkage() {
// Disabling for MSVC as it gives a hard error on using local types:
///
// error C7631:
// 'boost::pfr::detail::do_not_use_PFR_with_local_types<testing::unnamed_t>':
// variable with internal linkage declared but not defined
#ifndef _MSC_VER
struct function_local {
int val;
};
Expand All @@ -68,6 +74,7 @@ void test_get_name_by_id_without_linkage() {
BOOST_TEST_EQ( ((boost::pfr::get_name<0, inside_unnamed_ns>())), "hidden");

BOOST_TEST_EQ( ((boost::pfr::get_name<0, function_local>())), "val");
#endif
}

void test_get_name_by_type() {
Expand Down Expand Up @@ -100,6 +107,12 @@ void test_names_as_array() {
}

void test_names_as_array_without_linkage() {
// Disabling for MSVC as it gives a hard error on using local types:
///
// error C7631:
// 'boost::pfr::detail::do_not_use_PFR_with_local_types<testing::unnamed_t>':
// variable with internal linkage declared but not defined
#ifndef _MSC_VER
const auto expected = std::array<std::string_view, 2>{
"unnamed_first",
"unnamed_second"
Expand All @@ -109,6 +122,7 @@ void test_names_as_array_without_linkage() {
for (std::size_t i=0;i<expected.size();++i) {
BOOST_TEST_EQ(value[i], expected[i]);
}
#endif
}

void test_names_as_array_for_empty() {
Expand Down

0 comments on commit 9b90f2f

Please sign in to comment.