diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7f5fe71f7..d09b640fe 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -118,6 +118,16 @@ jobs: - name: build run: cmake --build build --target ci_test_amalgamation + ci_test_diagnostics: + runs-on: ubuntu-latest + container: nlohmann/json-ci:latest + steps: + - uses: actions/checkout@v2 + - name: cmake + run: cmake -S . -B build -DJSON_CI=On + - name: build + run: cmake --build build --target ci_test_diagnostics + ci_test_noexceptions: runs-on: ubuntu-latest container: nlohmann/json-ci:latest diff --git a/cmake/ci.cmake b/cmake/ci.cmake index bd0261d58..5085c369d 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -431,7 +431,7 @@ add_custom_target(ci_test_noexceptions -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noexceptions COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noexceptions COMMAND cd ${PROJECT_BINARY_DIR}/build_noexceptions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with with exceptions switched off" + COMMENT "Compile and test with exceptions switched off" ) ############################################################################### @@ -445,7 +445,21 @@ add_custom_target(ci_test_noimplicitconversions -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_noimplicitconversions COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_noimplicitconversions COMMAND cd ${PROJECT_BINARY_DIR}/build_noimplicitconversions && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure - COMMENT "Compile and test with with implicit conversions switched off" + COMMENT "Compile and test with implicit conversions switched off" +) + +############################################################################### +# Enable improved diagnostics. +############################################################################### + +add_custom_target(ci_test_diagnostics + COMMAND CXX=${CLANG_TOOL} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_MultipleHeaders=ON -DJSON_Diagnostics=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_diagnostics + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_diagnostics + COMMAND cd ${PROJECT_BINARY_DIR}/build_diagnostics && ${CMAKE_CTEST_COMMAND} --parallel ${N} --output-on-failure + COMMENT "Compile and test with improved diagnostics enabled" ) ############################################################################### @@ -741,7 +755,7 @@ else() ) endif() -set(JSON_CMAKE_FLAGS "JSON_BuildTests;JSON_Install;JSON_MultipleHeaders;JSON_Sanitizer;JSON_Valgrind;JSON_NoExceptions;JSON_Coverage") +set(JSON_CMAKE_FLAGS "JSON_BuildTests;JSON_Install;JSON_MultipleHeaders;JSON_Sanitizer;JSON_Valgrind;JSON_NoExceptions;JSON_Coverage;JSON_Diagnostics") foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS}) string(TOLOWER "ci_cmake_flag_${JSON_CMAKE_FLAG}" JSON_CMAKE_FLAG_TARGET) diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 74fd048a3..8ad5d123a 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -3,6 +3,7 @@ #include // exception #include // runtime_error #include // to_string +#include // vector #include #include @@ -118,6 +119,7 @@ class exception : public std::exception return a + "/" + detail::escape(b); }) + ") "; #else + static_cast(leaf_element); return ""; #endif } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 032d1ebd1..c43c5e798 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -72,6 +72,7 @@ SOFTWARE. #include // exception #include // runtime_error #include // to_string +#include // vector // #include @@ -2705,6 +2706,7 @@ class exception : public std::exception return a + "/" + detail::escape(b); }) + ") "; #else + static_cast(leaf_element); return ""; #endif }