From d8e4a84080ebcd0cd61d36386461ebd3d506c1fe Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 13 Oct 2025 12:35:38 -0400 Subject: [PATCH] Added unit test to verify that using error objects of pointer types results in a diagnostic --- .github/workflows/ci.yml | 47 ++++++++++++++++------------ test/Jamfile.v2 | 1 + test/_compile-fail-error_obj_ptr.cpp | 13 ++++++++ test/diagnostics_test4.cpp | 3 +- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 test/_compile-fail-error_obj_ptr.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07cf959..d8601ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,34 +19,34 @@ jobs: include: - toolset: gcc-5 cxxstd: "11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-5 - toolset: gcc-6 cxxstd: "11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-6 - toolset: gcc-7 cxxstd: "11,14" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest - toolset: gcc-8 cxxstd: "11,14,17,2a" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: g++-8 - toolset: gcc-9 cxxstd: "11,14,17,2a" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest - toolset: gcc-10 cxxstd: "11,14,17,2a" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: g++-10 - toolset: gcc-11 - cxxstd: "11,14,17,20" + cxxstd: "11,14,17,2a" os: ubuntu-22.04 - toolset: gcc-12 cxxstd: "11,14,17,20,2b" @@ -62,6 +62,11 @@ jobs: os: ubuntu-latest container: ubuntu:24.04 install: g++-14 + - toolset: gcc-15 + cxxstd: "11,14,17,20,23,2c" + os: ubuntu-latest + container: ubuntu:25.04 + install: g++-15 - toolset: clang compiler: clang++-3.9 cxxstd: "11,14" @@ -83,44 +88,44 @@ jobs: - toolset: clang compiler: clang++-6.0 cxxstd: "11,14,17" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-6.0 - toolset: clang compiler: clang++-7 cxxstd: "11,14,17" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-7 - toolset: clang compiler: clang++-8 cxxstd: "11,14,17" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-8 - toolset: clang compiler: clang++-9 cxxstd: "11,14,17" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-9 - toolset: clang compiler: clang++-10 cxxstd: "11,14,17,2a" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-10 - toolset: clang compiler: clang++-11 cxxstd: "11,14,17,2a" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-11 - toolset: clang compiler: clang++-12 cxxstd: "11,14,17,20" - os: ubuntu-latest container: ubuntu:20.04 + os: ubuntu-latest install: clang-12 - toolset: clang compiler: clang++-13 @@ -161,9 +166,15 @@ jobs: - toolset: clang compiler: clang++-19 cxxstd: "11,14,17,20,2b" - container: ubuntu:24.10 + container: ubuntu:24.04 os: ubuntu-latest install: clang-19 + - toolset: clang + compiler: clang++-20 + cxxstd: "11,14,17,20,23,2c" + container: ubuntu:25.04 + os: ubuntu-latest + install: clang-20 - toolset: clang cxxstd: "11,14,17,20,2b" os: macos-13 @@ -250,10 +261,6 @@ jobs: fail-fast: false matrix: include: - - toolset: msvc-14.2 - cxxstd: "14,17,20,latest" - addrmd: 32,64 - os: windows-2019 - toolset: msvc-14.3 cxxstd: "14,17,20,latest" addrmd: 32,64 @@ -265,7 +272,7 @@ jobs: - toolset: gcc cxxstd: "11,14,17,2a" addrmd: 64 - os: windows-2019 + os: windows-2022 runs-on: ${{matrix.os}} diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index added3b..355d2ff 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -145,6 +145,7 @@ compile-fail _compile-fail-BOOST_LEAF_AUTO.cpp ; compile-fail _compile-fail-diagnostic_details.cpp ; compile-fail _compile-fail-diagnostic_info.cpp ; compile-fail _compile-fail-error_info.cpp ; +compile-fail _compile-fail-error_obj_ptr.cpp ; compile-fail _compile-fail-exception_1.cpp ; compile-fail _compile-fail-exception_2.cpp ; compile-fail _compile-fail-new_error.cpp ; diff --git a/test/_compile-fail-error_obj_ptr.cpp b/test/_compile-fail-error_obj_ptr.cpp new file mode 100644 index 0000000..9059267 --- /dev/null +++ b/test/_compile-fail-error_obj_ptr.cpp @@ -0,0 +1,13 @@ +// Copyright 2018-2024 Emil Dotchevski and Reverge Studios, Inc. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +namespace leaf = boost::leaf; + +void f() +{ + int x; + (void) leaf::new_error(&x); +} diff --git a/test/diagnostics_test4.cpp b/test/diagnostics_test4.cpp index c6bbad0..bc1f559 100644 --- a/test/diagnostics_test4.cpp +++ b/test/diagnostics_test4.cpp @@ -40,7 +40,7 @@ struct my_error leaf::result f1() { auto ctx_ = leaf::on_error([](my_error & e) {e.append(42);}); - return leaf::new_error("new_error"); + return leaf::new_error(); } leaf::result f2() @@ -64,7 +64,6 @@ int main() std::cout << s << std::endl; if( BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_CAPTURE ) { - BOOST_TEST_NE(s.find("new_error"), s.npos); BOOST_TEST_NE(s.find("appended: 42"), s.npos); BOOST_TEST_NE(s.find("appended: 43"), s.npos); }