From bd0ee6adbe3a4c94def73c106ba9a92ffd9ee8e9 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Thu, 14 Apr 2022 16:26:09 +0430 Subject: [PATCH 1/7] Add GCC compiler flag. (see #2094) --- src/catch2/benchmark/catch_optimizer.hpp | 3 ++- src/catch2/catch_template_test_macros.hpp | 4 +++- src/catch2/internal/catch_clara.hpp | 4 ++-- src/catch2/internal/catch_compiler_capabilities.hpp | 6 +++++- src/catch2/internal/catch_debugger.hpp | 3 ++- src/catch2/internal/catch_decomposer.hpp | 4 ++-- src/catch2/internal/catch_fatal_condition_handler.cpp | 5 +++-- src/catch2/internal/catch_preprocessor.hpp | 3 ++- src/catch2/internal/catch_source_line_info.cpp | 2 +- src/catch2/internal/catch_stream.hpp | 5 +++-- src/catch2/internal/catch_template_test_registry.hpp | 2 +- src/catch2/internal/catch_test_macro_impl.hpp | 3 ++- src/catch2/internal/catch_test_registry.hpp | 3 ++- tests/SelfTest/UsageTests/Compilation.tests.cpp | 6 ++++-- tests/SelfTest/UsageTests/Condition.tests.cpp | 4 ++-- tests/SelfTest/UsageTests/Message.tests.cpp | 8 ++++---- tests/SelfTest/UsageTests/ToStringWhich.tests.cpp | 4 ++-- 17 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/catch2/benchmark/catch_optimizer.hpp b/src/catch2/benchmark/catch_optimizer.hpp index b9af3ea1de..30dd7594f4 100644 --- a/src/catch2/benchmark/catch_optimizer.hpp +++ b/src/catch2/benchmark/catch_optimizer.hpp @@ -14,13 +14,14 @@ # include // atomic_thread_fence #endif +#include #include #include namespace Catch { namespace Benchmark { -#if defined(__GNUC__) || defined(__clang__) +#if defined(CATCH_COMPILER_GCC) || defined(__clang__) template inline void keep_memory(T* p) { asm volatile("" : : "g"(p) : "memory"); diff --git a/src/catch2/catch_template_test_macros.hpp b/src/catch2/catch_template_test_macros.hpp index 66b1bc4de2..df30ddd0e8 100644 --- a/src/catch2/catch_template_test_macros.hpp +++ b/src/catch2/catch_template_test_macros.hpp @@ -8,11 +8,13 @@ #ifndef CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED #define CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED +#include + // We need this suppression to leak, because it took until GCC 10 // for the front end to handle local suppression via _Pragma properly // inside templates (so `TEMPLATE_TEST_CASE` and co). // **THIS IS DIFFERENT FOR STANDARD TESTS, WHERE GCC 9 IS SUFFICIENT** -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 10 +#if defined(CATCH_COMPILER_GCC) && __GNUC__ < 10 #pragma GCC diagnostic ignored "-Wparentheses" #endif diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 00761c0af6..93be04696c 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -15,7 +15,7 @@ # pragma clang diagnostic ignored "-Wdeprecated" #endif -#if defined( __GNUC__ ) +#if defined( CATCH_COMPILER_GCC ) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-conversion" #endif @@ -702,7 +702,7 @@ namespace Catch { # pragma clang diagnostic pop #endif -#if defined( __GNUC__ ) +#if defined( CATCH_COMPILER_GCC ) # pragma GCC diagnostic pop #endif diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 5c5c8f642a..e2d44dc187 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -27,6 +27,10 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +#define CATCH_COMPILER_GCC +#endif + #ifdef __cplusplus # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) @@ -41,7 +45,7 @@ // Only GCC compiler should be used in this block, so other compilers trying to // mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +#if defined(CATCH_COMPILER_GCC) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index c300da72cd..9bb80194f3 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_DEBUGGER_HPP_INCLUDED #define CATCH_DEBUGGER_HPP_INCLUDED +#include #include namespace Catch { @@ -39,7 +40,7 @@ namespace Catch { // If we can use inline assembler, do it because this allows us to break // directly at the location of the failing check instead of breaking inside // raise() called from it, i.e. one stack frame below. - #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #if defined(CATCH_COMPILER_GCC) && (defined(__i386) || defined(__x86_64)) #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ #else // Fall back to the generic way. #include diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index e7dd1e9a42..7f4dcc8f59 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -26,7 +26,7 @@ #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-compare" -#elif defined __GNUC__ +#elif defined CATCH_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" #endif @@ -261,7 +261,7 @@ namespace Catch { #endif #ifdef __clang__ # pragma clang diagnostic pop -#elif defined __GNUC__ +#elif defined CATCH_COMPILER_GCC # pragma GCC diagnostic pop #endif diff --git a/src/catch2/internal/catch_fatal_condition_handler.cpp b/src/catch2/internal/catch_fatal_condition_handler.cpp index 410b9b8fb6..754d643bc4 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.cpp +++ b/src/catch2/internal/catch_fatal_condition_handler.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -160,7 +161,7 @@ namespace Catch { // Older GCCs trigger -Wmissing-field-initializers for T foo = {} // which is zero initialization, but not explicit. We want to avoid // that. -#if defined(__GNUC__) +#if defined(CATCH_COMPILER_GCC) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif @@ -228,7 +229,7 @@ namespace Catch { } } -#if defined(__GNUC__) +#if defined(CATCH_COMPILER_GCC) # pragma GCC diagnostic pop #endif diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 00859b150a..80023a1896 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -8,8 +8,9 @@ #ifndef CATCH_PREPROCESSOR_HPP_INCLUDED #define CATCH_PREPROCESSOR_HPP_INCLUDED +#include -#if defined(__GNUC__) +#if defined(CATCH_COMPILER_GCC) // We need to silence "empty __VA_ARGS__ warning", and using just _Pragma does not work #pragma GCC system_header #endif diff --git a/src/catch2/internal/catch_source_line_info.cpp b/src/catch2/internal/catch_source_line_info.cpp index 9a4fe74e51..1f8c5966aa 100644 --- a/src/catch2/internal/catch_source_line_info.cpp +++ b/src/catch2/internal/catch_source_line_info.cpp @@ -22,7 +22,7 @@ namespace Catch { } std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ +#if !defined(CATCH_COMPILER_GCC) || !defined(__cplusplus) os << info.file << '(' << info.line << ')'; #else os << info.file << ':' << info.line; diff --git a/src/catch2/internal/catch_stream.hpp b/src/catch2/internal/catch_stream.hpp index eab7161c4d..a3397a8633 100644 --- a/src/catch2/internal/catch_stream.hpp +++ b/src/catch2/internal/catch_stream.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_STREAM_HPP_INCLUDED #define CATCH_STREAM_HPP_INCLUDED +#include #include #include @@ -65,7 +66,7 @@ namespace Catch { //! Sets internal state to `str` void str(std::string const& str); -#if defined(__GNUC__) && !defined(__clang__) +#if defined(CATCH_COMPILER_GCC) #pragma GCC diagnostic push // Old versions of GCC do not understand -Wnonnull-compare #pragma GCC diagnostic ignored "-Wpragmas" @@ -83,7 +84,7 @@ namespace Catch { return *this; } -#if defined(__GNUC__) && !defined(__clang__) +#if defined(CATCH_COMPILER_GCC) #pragma GCC diagnostic pop #endif auto get() -> std::ostream& { return *m_oss; } diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index bfac3bc81d..e45ad9524b 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -18,7 +18,7 @@ // GCC 5 and older do not properly handle disabling unused-variable warning // with a _Pragma. This means that we have to leak the suppression to the // user code as well :-( -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 +#if defined(CATCH_COMPILER_GCC) && __GNUC__ <= 5 #pragma GCC diagnostic ignored "-Wunused-variable" #endif diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp index 7181204059..55a6534b11 100644 --- a/src/catch2/internal/catch_test_macro_impl.hpp +++ b/src/catch2/internal/catch_test_macro_impl.hpp @@ -10,13 +10,14 @@ #include #include +#include #include #include #include // We need this suppression to leak, because it took until GCC 9 // for the front end to handle local suppression via _Pragma properly -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 9 +#if defined(CATCH_COMPILER_GCC) && __GNUC__ < 9 #pragma GCC diagnostic ignored "-Wparentheses" #endif diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 9a03e6dbfa..1b0d099f57 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED #define CATCH_TEST_REGISTRY_HPP_INCLUDED +#include #include #include #include @@ -18,7 +19,7 @@ // GCC 5 and older do not properly handle disabling unused-variable warning // with a _Pragma. This means that we have to leak the suppression to the // user code as well :-( -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 +#if defined(CATCH_COMPILER_GCC) && __GNUC__ <= 5 #pragma GCC diagnostic ignored "-Wunused-variable" #endif diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index d45f8e6c5f..b05e6ce0d7 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -12,6 +12,8 @@ // in a different namespace. #include +#include + namespace foo { struct helper_1403 { bool operator==(helper_1403) const { return true; } @@ -23,7 +25,7 @@ namespace bar { struct TypeList {}; } -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif std::ostream& operator<<(std::ostream& out, foo::helper_1403 const&) { @@ -79,7 +81,7 @@ struct B : private A { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" #endif -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC // Note that because -~GCC~-, this warning cannot be silenced temporarily, by pushing diagnostic stack... // Luckily it is firing in test files and thus can be silenced for the whole file, without losing much. #pragma GCC diagnostic ignored "-Wunused-function" diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index 198b4cdb3d..59709caa5a 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -223,7 +223,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne // Disable warnings about sign conversions for the next two tests // (as we are deliberately invoking them) // - Currently only disabled for GCC/ LLVM. Should add VC++ too -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -277,7 +277,7 @@ TEST_CASE( "Comparisons between ints where one side is computed" ) CHECK( 54 == 6*9 ); } -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 2ec71b4965..23a8f5eaf5 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -216,7 +216,7 @@ TEST_CASE( "CAPTURE can deal with complex expressions", "[messages][capture]" ) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-value" // In (1, 2), the "1" is unused ... #endif -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-value" // All the comma operators are side-effect free #endif @@ -243,7 +243,7 @@ std::ostream& operator<<(std::ostream& out, helper_1436 const& helper) { // Clang and gcc have different names for this warning, and clang also // warns about an unused value. This warning must be disabled for C++20. -#if defined(__GNUG__) && !defined(__clang__) +#if defined(CATCH_COMPILER_GCC) && __cplusplus #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wcomma-subscript" @@ -265,7 +265,7 @@ TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messag SUCCEED(); } -#ifdef __GNUG__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic pop #endif @@ -279,7 +279,7 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]" #ifdef __clang__ #pragma clang diagnostic pop #endif -#ifdef __GNUC__ +#ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic pop #endif #ifdef _MSC_VER diff --git a/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp b/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp index 7069734f45..4f78633811 100644 --- a/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp +++ b/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp @@ -8,9 +8,9 @@ #include +#include - -#if defined(__GNUC__) +#if defined(CATCH_COMPILER_GCC) // This has to be left enabled until end of the TU, because the GCC // frontend reports operator<<(std::ostream& os, const has_maker_and_operator&) // as unused anyway From c665fd7f509226b802b5e063820b2d145f14ed6e Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Thu, 14 Apr 2022 16:46:59 +0430 Subject: [PATCH 2/7] Add clang compiler flag. (see #2094) --- examples/231-Cfg-OutputStreams.cpp | 4 +++- src/catch2/benchmark/catch_optimizer.hpp | 2 +- src/catch2/benchmark/detail/catch_estimate_clock.hpp | 5 +++-- src/catch2/catch_test_case_info.hpp | 5 +++-- src/catch2/catch_test_spec.hpp | 6 ++++-- src/catch2/internal/catch_clara.hpp | 5 +++-- src/catch2/internal/catch_compiler_capabilities.hpp | 9 +++++++-- src/catch2/internal/catch_console_colour.cpp | 5 +++-- src/catch2/internal/catch_decomposer.hpp | 5 +++-- src/catch2/internal/catch_test_case_tracker.cpp | 5 +++-- src/catch2/internal/catch_test_spec_parser.hpp | 5 +++-- src/catch2/matchers/catch_matchers_floating_point.cpp | 5 +++-- src/catch2/reporters/catch_reporter_console.cpp | 5 +++-- src/catch2/reporters/catch_reporter_teamcity.hpp | 5 +++-- tests/ExtraTests/X02-DisabledMacros.cpp | 7 ++++--- tests/SelfTest/TestRegistrations.cpp | 7 ++++--- tests/SelfTest/UsageTests/Compilation.tests.cpp | 4 ++-- tests/SelfTest/UsageTests/Condition.tests.cpp | 6 ++++-- tests/SelfTest/UsageTests/Exception.tests.cpp | 5 +++-- tests/SelfTest/UsageTests/Generators.tests.cpp | 5 +++-- tests/SelfTest/UsageTests/Matchers.tests.cpp | 5 +++-- tests/SelfTest/UsageTests/MatchersRanges.tests.cpp | 5 +++-- tests/SelfTest/UsageTests/Message.tests.cpp | 7 ++++--- tests/SelfTest/UsageTests/Misc.tests.cpp | 3 ++- tests/SelfTest/UsageTests/Tricky.tests.cpp | 4 +++- 25 files changed, 80 insertions(+), 49 deletions(-) diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp index b77c127354..5dccd54152 100644 --- a/examples/231-Cfg-OutputStreams.cpp +++ b/examples/231-Cfg-OutputStreams.cpp @@ -10,6 +10,8 @@ #include #include +#include + class out_buff : public std::stringbuf { std::FILE* m_stream; public: @@ -31,7 +33,7 @@ class out_buff : public std::stringbuf { out_buff::~out_buff() { pubsync(); } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic ignored "-Wexit-time-destructors" // static variables in cout/cerr/clog #endif diff --git a/src/catch2/benchmark/catch_optimizer.hpp b/src/catch2/benchmark/catch_optimizer.hpp index 30dd7594f4..b327852ca4 100644 --- a/src/catch2/benchmark/catch_optimizer.hpp +++ b/src/catch2/benchmark/catch_optimizer.hpp @@ -21,7 +21,7 @@ namespace Catch { namespace Benchmark { -#if defined(CATCH_COMPILER_GCC) || defined(__clang__) +#if defined(CATCH_COMPILER_GCC) || defined(CATCH_COMPILER_CLANG) template inline void keep_memory(T* p) { asm volatile("" : : "g"(p) : "memory"); diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp index c392ca4f7e..0ae439f1a1 100644 --- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp +++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -95,12 +96,12 @@ namespace Catch { template Environment> measure_environment() { -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wexit-time-destructors" #endif static Catch::Detail::unique_ptr>> env; -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic pop #endif if (env) { diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 6cfc2aaf99..5477ccc2f1 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED +#include #include #include #include @@ -18,7 +19,7 @@ #include #include -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif @@ -123,7 +124,7 @@ namespace Catch { SourceLineInfo const& lineInfo ); } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif diff --git a/src/catch2/catch_test_spec.hpp b/src/catch2/catch_test_spec.hpp index 499bfaa56c..9f1556903b 100644 --- a/src/catch2/catch_test_spec.hpp +++ b/src/catch2/catch_test_spec.hpp @@ -8,7 +8,9 @@ #ifndef CATCH_TEST_SPEC_HPP_INCLUDED #define CATCH_TEST_SPEC_HPP_INCLUDED -#ifdef __clang__ +#include + +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif @@ -81,7 +83,7 @@ namespace Catch { }; } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 93be04696c..3010225125 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_CLARA_HPP_INCLUDED #define CATCH_CLARA_HPP_INCLUDED -#if defined( __clang__ ) +#if defined( CATCH_COMPILER_CLANG ) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wshadow" @@ -29,6 +29,7 @@ # endif #endif +#include #include #include #include @@ -698,7 +699,7 @@ namespace Catch { } // namespace Clara } // namespace Catch -#if defined( __clang__ ) +#if defined( CATCH_COMPILER_CLANG ) # pragma clang diagnostic pop #endif diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index e2d44dc187..c98a2791f0 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -24,6 +24,7 @@ // Many features, at point of detection, define an _INTERNAL_ macro, so they // can be combined, en-mass, with the _NO_ forms later. +#include #include #include @@ -31,6 +32,10 @@ #define CATCH_COMPILER_GCC #endif +#if defined(__clang__) && !defined(_MSC_VER) +#define CATCH_COMPILER_CLANG +#endif + #ifdef __cplusplus # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) @@ -61,7 +66,7 @@ #endif -#if defined(__clang__) && !defined(_MSC_VER) +#if defined(CATCH_COMPILER_CLANG) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) @@ -103,7 +108,7 @@ # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) -#endif // __clang__ +#endif // CATCH_COMPILER_CLANG //////////////////////////////////////////////////////////////////////////////// diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index e9fa55f73a..54ea3a7046 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -5,12 +5,13 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wexit-time-destructors" #endif +#include #include #include #include @@ -277,7 +278,7 @@ namespace Catch { } // end namespace Catch -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic pop #endif diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 7f4dcc8f59..8d64eded13 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -9,6 +9,7 @@ #define CATCH_DECOMPOSER_HPP_INCLUDED #include +#include #include #include @@ -23,7 +24,7 @@ #pragma warning(disable:4800) // Forcing result to true or false #endif -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-compare" #elif defined CATCH_COMPILER_GCC @@ -259,7 +260,7 @@ namespace Catch { #ifdef _MSC_VER #pragma warning(pop) #endif -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic pop #elif defined CATCH_COMPILER_GCC # pragma GCC diagnostic pop diff --git a/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp index ce76dcba89..7fd7fc55e6 100644 --- a/src/catch2/internal/catch_test_case_tracker.cpp +++ b/src/catch2/internal/catch_test_case_tracker.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include #include #include @@ -14,7 +15,7 @@ #include #include -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wexit-time-destructors" #endif @@ -245,6 +246,6 @@ namespace TestCaseTracking { } // namespace Catch -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic pop #endif diff --git a/src/catch2/internal/catch_test_spec_parser.hpp b/src/catch2/internal/catch_test_spec_parser.hpp index 75f2fd760c..1a216be3f2 100644 --- a/src/catch2/internal/catch_test_spec_parser.hpp +++ b/src/catch2/internal/catch_test_spec_parser.hpp @@ -8,11 +8,12 @@ #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif +#include #include #include @@ -75,7 +76,7 @@ namespace Catch { } // namespace Catch -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif diff --git a/src/catch2/matchers/catch_matchers_floating_point.cpp b/src/catch2/matchers/catch_matchers_floating_point.cpp index ad0fd378c5..f88548472d 100644 --- a/src/catch2/matchers/catch_matchers_floating_point.cpp +++ b/src/catch2/matchers/catch_matchers_floating_point.cpp @@ -6,6 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include #include #include @@ -115,7 +116,7 @@ namespace Detail { "IEEE-754 compatible floating point representation" ); } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic push // Clang <3.5 reports on the default branch in the switch below #pragma clang diagnostic ignored "-Wunreachable-code" @@ -132,7 +133,7 @@ namespace Detail { } } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic pop #endif diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index b8e64fb3cc..f0b7751e67 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,7 @@ // Note that 4062 (not all labels are handled and default is missing) is enabled #endif -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push // For simplicity, benchmarking-only helpers are always enabled # pragma clang diagnostic ignored "-Wunused-function" @@ -714,6 +715,6 @@ void ConsoleReporter::printTestFilters() { #pragma warning(pop) #endif -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic pop #endif diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp index 5007193bbe..b15c04a77a 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.hpp +++ b/src/catch2/reporters/catch_reporter_teamcity.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED +#include #include #include #include -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wpadded" #endif @@ -59,7 +60,7 @@ namespace Catch { } // end namespace Catch -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic pop #endif diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp index aea3b1a3e3..d2d8f1e5ae 100644 --- a/tests/ExtraTests/X02-DisabledMacros.cpp +++ b/tests/ExtraTests/X02-DisabledMacros.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -28,7 +29,7 @@ struct foo { } }; -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wglobal-constructors" #endif @@ -36,7 +37,7 @@ struct foo { foo f; -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) // The test is unused since the registration is disabled #pragma clang diagnostic ignored "-Wunused-function" #endif @@ -60,6 +61,6 @@ TEST_CASE( "Disabled Macros" ) { BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); }; } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/TestRegistrations.cpp b/tests/SelfTest/TestRegistrations.cpp index 2586ffabbd..d5d9b5643d 100644 --- a/tests/SelfTest/TestRegistrations.cpp +++ b/tests/SelfTest/TestRegistrations.cpp @@ -7,9 +7,10 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include -#include #include +#include +#include +#include #include @@ -17,7 +18,7 @@ CATCH_REGISTER_TAG_ALIAS("[@nhf]", "[failing]~[.]") CATCH_REGISTER_TAG_ALIAS("[@tricky]", "[tricky]~[.]") -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wc++98-compat" diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index b05e6ce0d7..2c049a320e 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -77,7 +77,7 @@ struct B : private A { bool operator==(int) const { return true; } }; -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" #endif @@ -91,7 +91,7 @@ B f(); std::ostream g(); -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index 59709caa5a..da7ac0e776 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -6,7 +6,9 @@ // SPDX-License-Identifier: BSL-1.0 -#ifdef __clang__ +#include + +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wpadded" // Wdouble-promotion is not supported until 3.8 @@ -188,7 +190,7 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) CHECK( data.str_hello <= "a" ); } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Exception.tests.cpp b/tests/SelfTest/UsageTests/Exception.tests.cpp index 9b6d2a5823..6e0d32210a 100644 --- a/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -16,7 +17,7 @@ #ifdef _MSC_VER #pragma warning(disable:4702) // Unreachable code -- unconditional throws and so on #endif -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wweak-vtables" #pragma clang diagnostic ignored "-Wmissing-noreturn" @@ -196,6 +197,6 @@ TEST_CASE( "#748 - captures with unexpected exceptions", "[.][failing][!throws][ } } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp index 5b205c85c7..30ef24a4f5 100644 --- a/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include #include #include @@ -235,7 +236,7 @@ namespace { } } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wexit-time-destructors" #endif @@ -277,6 +278,6 @@ TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") { REQUIRE(i != j); } -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index afb124950d..cee4efe7f8 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,7 @@ #include #include -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wpadded" @@ -1083,7 +1084,7 @@ TEST_CASE( "Matchers can take references", REQUIRE_THAT( 22, ReferencingMatcher{} ); } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp index 1e4b252e3e..42a6f30ca7 100644 --- a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +++ b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include #include #include @@ -46,7 +47,7 @@ namespace unrelated { }; } // end unrelated namespace -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunused-function" #endif @@ -107,7 +108,7 @@ class has_different_begin_end_types { } }; -#if defined(__clang__) +#if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic pop #endif diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 23a8f5eaf5..0612f38013 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) { @@ -212,7 +213,7 @@ TEST_CASE( "CAPTURE can deal with complex expressions", "[messages][capture]" ) SUCCEED(); } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-value" // In (1, 2), the "1" is unused ... #endif @@ -247,7 +248,7 @@ std::ostream& operator<<(std::ostream& out, helper_1436 const& helper) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wcomma-subscript" -#elif defined(__clang__) +#elif defined(CATCH_COMPILER_CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunknown-warning-option" @@ -276,7 +277,7 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]" SUCCEED(); } -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic pop #endif #ifdef CATCH_COMPILER_GCC diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp index 33734d436b..829f50860b 100644 --- a/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -8,10 +8,11 @@ #include #include +#include #include #include -#ifdef __clang__ +#ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic ignored "-Wc++98-compat" # pragma clang diagnostic ignored "-Wc++98-compat-pedantic" #endif diff --git a/tests/SelfTest/UsageTests/Tricky.tests.cpp b/tests/SelfTest/UsageTests/Tricky.tests.cpp index bcfa7e699d..c304e617dc 100644 --- a/tests/SelfTest/UsageTests/Tricky.tests.cpp +++ b/tests/SelfTest/UsageTests/Tricky.tests.cpp @@ -6,7 +6,9 @@ // SPDX-License-Identifier: BSL-1.0 -#ifdef __clang__ +#include + +#ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic ignored "-Wpadded" #endif From e3aaa40fe7b88bcb72e51b95f0820dd3b79d21a9 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Thu, 14 Apr 2022 17:23:59 +0430 Subject: [PATCH 3/7] Add MSVC compiler flag. (see #2094) --- src/catch2/benchmark/catch_optimizer.hpp | 7 ++++--- src/catch2/catch_config.cpp | 6 ++++-- src/catch2/catch_tostring.hpp | 8 ++++---- src/catch2/internal/catch_compiler_capabilities.hpp | 8 ++++++-- .../internal/catch_config_uncaught_exceptions.hpp | 4 +++- src/catch2/internal/catch_container_nonmembers.hpp | 2 +- src/catch2/internal/catch_debugger.cpp | 4 +++- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_decomposer.hpp | 4 ++-- src/catch2/internal/catch_output_redirect.cpp | 10 ++++++---- src/catch2/internal/catch_output_redirect.hpp | 2 +- src/catch2/internal/catch_platform.hpp | 4 +++- src/catch2/internal/catch_random_number_generator.cpp | 6 ++++-- src/catch2/reporters/catch_reporter_combined_tu.cpp | 4 +++- src/catch2/reporters/catch_reporter_console.cpp | 4 ++-- src/catch2/reporters/catch_reporter_junit.cpp | 3 ++- src/catch2/reporters/catch_reporter_xml.cpp | 5 +++-- tests/SelfTest/IntrospectiveTests/Details.tests.cpp | 5 +++-- tests/SelfTest/UsageTests/Compilation.tests.cpp | 4 ++-- tests/SelfTest/UsageTests/Condition.tests.cpp | 2 +- tests/SelfTest/UsageTests/Exception.tests.cpp | 2 +- tests/SelfTest/UsageTests/Matchers.tests.cpp | 2 +- tests/SelfTest/UsageTests/Message.tests.cpp | 4 ++-- tests/SelfTest/UsageTests/Tricky.tests.cpp | 2 +- third_party/clara.hpp | 4 +++- 25 files changed, 66 insertions(+), 42 deletions(-) diff --git a/src/catch2/benchmark/catch_optimizer.hpp b/src/catch2/benchmark/catch_optimizer.hpp index b327852ca4..549b3e8561 100644 --- a/src/catch2/benchmark/catch_optimizer.hpp +++ b/src/catch2/benchmark/catch_optimizer.hpp @@ -10,11 +10,12 @@ #ifndef CATCH_OPTIMIZER_HPP_INCLUDED #define CATCH_OPTIMIZER_HPP_INCLUDED -#if defined(_MSC_VER) +#include + +#if defined(CATCH_COMPILER_MSC) # include // atomic_thread_fence #endif -#include #include #include @@ -33,7 +34,7 @@ namespace Catch { namespace Detail { inline void optimizer_barrier() { keep_memory(); } } // namespace Detail -#elif defined(_MSC_VER) +#elif defined(CATCH_COMPILER_MSC) #pragma optimize("", off) template diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 79ec33f838..852f0e463f 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -6,7 +6,9 @@ // SPDX-License-Identifier: BSL-1.0 #include + #include +#include #include #include #include @@ -68,14 +70,14 @@ namespace Catch { // during test, Bazel will not generate a default XML output. // This allows the XML output file to contain higher level of detail // than what is possible otherwise. -# if defined( _MSC_VER ) +# if defined( CATCH_COMPILER_MSC ) // On Windows getenv throws a warning as there is no input validation, // since the key is hardcoded, this should not be an issue. # pragma warning( push ) # pragma warning( disable : 4996 ) # endif const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" ); -# if defined( _MSC_VER ) +# if defined( CATCH_COMPILER_MSC ) # pragma warning( pop ) # endif if ( bazelOutputFilePtr != nullptr ) { diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index 9182a119fe..b6d416c10a 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -25,7 +25,7 @@ #include #endif -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(push) #pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless #endif @@ -625,7 +625,7 @@ struct ratio_string { static std::string convert(std::chrono::time_point const& time_point) { auto converted = std::chrono::system_clock::to_time_t(time_point); -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC std::tm timeInfo = {}; gmtime_s(&timeInfo, &converted); #else @@ -636,7 +636,7 @@ struct ratio_string { char timeStamp[timeStampSize]; const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); #else std::strftime(timeStamp, timeStampSize, fmt, timeInfo); @@ -660,7 +660,7 @@ namespace Catch { \ #define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ ) -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(pop) #endif diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index c98a2791f0..91c28baa76 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -32,10 +32,14 @@ #define CATCH_COMPILER_GCC #endif -#if defined(__clang__) && !defined(_MSC_VER) +#if defined(__clang__) #define CATCH_COMPILER_CLANG #endif +#if defined(_MSC_VER) && !defined(__clang__) +#define CATCH_COMPILER_MSC +#endif + #ifdef __cplusplus # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) @@ -164,7 +168,7 @@ //////////////////////////////////////////////////////////////////////////////// // Visual C++ -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) diff --git a/src/catch2/internal/catch_config_uncaught_exceptions.hpp b/src/catch2/internal/catch_config_uncaught_exceptions.hpp index c853e673c5..beabd31da4 100644 --- a/src/catch2/internal/catch_config_uncaught_exceptions.hpp +++ b/src/catch2/internal/catch_config_uncaught_exceptions.hpp @@ -17,7 +17,9 @@ #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED -#if defined(_MSC_VER) +#include + +#if defined(CATCH_COMPILER_MSC) # if _MSC_VER >= 1900 // Visual Studio 2015 or newer # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS # endif diff --git a/src/catch2/internal/catch_container_nonmembers.hpp b/src/catch2/internal/catch_container_nonmembers.hpp index d6f10eb5ed..b828415c5e 100644 --- a/src/catch2/internal/catch_container_nonmembers.hpp +++ b/src/catch2/internal/catch_container_nonmembers.hpp @@ -17,7 +17,7 @@ // for C++14 or C++ libraries with incomplete support. // We also have to handle that MSVC std lib will happily provide these // under older standards. -#if defined(CATCH_CPP17_OR_GREATER) || defined(_MSC_VER) +#if defined(CATCH_CPP17_OR_GREATER) || defined(CATCH_COMPILER_MSC) // We are already using this header either way, so there shouldn't // be much additional overhead in including it to get the feature diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index 3c80173a69..a07cb788b5 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -6,6 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 #include + +#include #include #include #include @@ -99,7 +101,7 @@ return false; } } // namespace Catch -#elif defined(_MSC_VER) +#elif defined(CATCH_COMPILER_MSC) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); namespace Catch { bool isDebuggerActive() { diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index 9bb80194f3..b16c14bab6 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -47,7 +47,7 @@ namespace Catch { #define CATCH_TRAP() raise(SIGTRAP) #endif -#elif defined(_MSC_VER) +#elif defined(CATCH_COMPILER_MSC) #define CATCH_TRAP() __debugbreak() #elif defined(__MINGW32__) extern "C" __declspec(dllimport) void __stdcall DebugBreak(); diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 8d64eded13..68390e72a9 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -15,7 +15,7 @@ #include -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(push) #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #pragma warning(disable:4018) // more "signed/unsigned mismatch" @@ -257,7 +257,7 @@ namespace Catch { } // end namespace Catch -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(pop) #endif #ifdef CATCH_COMPILER_CLANG diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 49cfaa0d3e..235cc07ac5 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -6,6 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 #include + +#include #include #include @@ -13,7 +15,7 @@ #include #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) + #if defined(CATCH_COMPILER_MSC) #include //_dup and _dup2 #define dup _dup #define dup2 _dup2 @@ -59,7 +61,7 @@ namespace Catch { #if defined(CATCH_CONFIG_NEW_CAPTURE) -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) TempFile::TempFile() { if (tmpnam_s(m_buffer)) { CATCH_RUNTIME_ERROR("Could not get a temp filename"); @@ -87,7 +89,7 @@ namespace Catch { std::fclose(m_file); // We manually create the file on Windows only, on Linux // it will be autodeleted -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) std::remove(m_buffer); #endif } @@ -137,7 +139,7 @@ namespace Catch { } // namespace Catch #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) + #if defined(CATCH_COMPILER_MSC) #undef dup #undef dup2 #undef fileno diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index fd7234ef14..1ccce57e8d 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -85,7 +85,7 @@ namespace Catch { private: std::FILE* m_file = nullptr; - #if defined(_MSC_VER) + #if defined(CATCH_COMPILER_MSC) char m_buffer[L_tmpnam] = { 0 }; #endif }; diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index 8ecf01ad29..3416123ad6 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -8,6 +8,8 @@ #ifndef CATCH_PLATFORM_HPP_INCLUDED #define CATCH_PLATFORM_HPP_INCLUDED +#include + // See e.g.: // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html #ifdef __APPLE__ @@ -22,7 +24,7 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) || defined(__MINGW32__) # define CATCH_PLATFORM_WINDOWS #endif diff --git a/src/catch2/internal/catch_random_number_generator.cpp b/src/catch2/internal/catch_random_number_generator.cpp index f71c2323a6..e154446dd8 100644 --- a/src/catch2/internal/catch_random_number_generator.cpp +++ b/src/catch2/internal/catch_random_number_generator.cpp @@ -7,11 +7,13 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include + namespace Catch { namespace { -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(push) #pragma warning(disable:4146) // we negate uint32 during the rotate #endif @@ -22,7 +24,7 @@ namespace { return (val >> count) | (val << (-count & mask)); } -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(pop) #endif diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp index 23c738cdce..fdd1064919 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp @@ -17,8 +17,10 @@ * of Catch2 has its own combined TU like this. */ + #include #include +#include #include #include #include @@ -68,7 +70,7 @@ namespace Catch { // Save previous errno, to prevent sprintf from overwriting it ErrnoGuard guard; -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC size_t printedLength = static_cast( sprintf_s( buffer, "%.3f", duration ) ); #else diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index f0b7751e67..20d7c1458c 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -23,7 +23,7 @@ #include -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(push) #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch // Note that 4062 (not all labels are handled and default is missing) is enabled @@ -711,7 +711,7 @@ void ConsoleReporter::printTestFilters() { } // end namespace Catch -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(pop) #endif diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 37546cd712..0d71da6854 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,7 @@ namespace Catch { std::time(&rawtime); std::tm timeInfo = {}; -#if defined (_MSC_VER) || defined (__MINGW32__) +#if defined (CATCH_COMPILER_MSC) || defined (__MINGW32__) gmtime_s(&timeInfo, &rawtime); #else gmtime_r(&rawtime, &timeInfo); diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index b34d7679c3..e34af221bb 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -10,12 +10,13 @@ #include #include #include +#include #include #include #include #include -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(push) #pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch // Note that 4062 (not all labels are handled @@ -300,6 +301,6 @@ namespace Catch { } // end namespace Catch -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(pop) #endif diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index 987910a948..d2a290e22a 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -6,12 +6,13 @@ // SPDX-License-Identifier: BSL-1.0 +#include #include #include #include #include -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(push) #pragma warning(disable:4702) // unreachable code in the macro expansions #endif @@ -24,7 +25,7 @@ TEST_CASE("Check that our error handling macros throw the right exceptions", "[! REQUIRE_NOTHROW([](){CATCH_ENFORCE(true, "");}()); } -#if defined(_MSC_VER) +#if defined(CATCH_COMPILER_MSC) #pragma warning(pop) // unreachable code in the macro expansions #endif diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index 2c049a320e..5b57e098e6 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -197,7 +197,7 @@ TEST_CASE("#1548", "[compilation]") { inline static void synchronizing_callback( void * ) { } } -#if defined (_MSC_VER) +#if defined (CATCH_COMPILER_MSC) #pragma warning(push) // The function pointer comparison below triggers warning because of // calling conventions @@ -207,7 +207,7 @@ TEST_CASE("#1548", "[compilation]") { TestClass test; REQUIRE(utility::synchronizing_callback != test.testMethod_uponComplete_arg); } -#if defined (_MSC_VER) +#if defined (CATCH_COMPILER_MSC) #pragma warning(pop) #endif diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index da7ac0e776..edd122d4ce 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -230,7 +230,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" #endif -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #endif diff --git a/tests/SelfTest/UsageTests/Exception.tests.cpp b/tests/SelfTest/UsageTests/Exception.tests.cpp index 6e0d32210a..9e8b731464 100644 --- a/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -14,7 +14,7 @@ #include #include -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(disable:4702) // Unreachable code -- unconditional throws and so on #endif #ifdef CATCH_COMPILER_CLANG diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index cee4efe7f8..f70e5602cf 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -41,7 +41,7 @@ namespace { static bool alwaysTrue( int ) { return true; } static bool alwaysFalse( int ) { return false; } -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC # pragma warning( disable : 4702 ) // Unreachable code -- MSVC 19 (VS 2015) // sees right through the indirection #endif diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 0612f38013..5a7dd35503 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -221,7 +221,7 @@ TEST_CASE( "CAPTURE can deal with complex expressions", "[messages][capture]" ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-value" // All the comma operators are side-effect free #endif -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(push) #pragma warning(disable:4709) // comma in indexing operator #endif @@ -283,6 +283,6 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]" #ifdef CATCH_COMPILER_GCC #pragma GCC diagnostic pop #endif -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning(pop) #endif diff --git a/tests/SelfTest/UsageTests/Tricky.tests.cpp b/tests/SelfTest/UsageTests/Tricky.tests.cpp index c304e617dc..5108c6a5c7 100644 --- a/tests/SelfTest/UsageTests/Tricky.tests.cpp +++ b/tests/SelfTest/UsageTests/Tricky.tests.cpp @@ -12,7 +12,7 @@ #pragma clang diagnostic ignored "-Wpadded" #endif -#ifdef _MSC_VER +#ifdef CATCH_COMPILER_MSC #pragma warning (disable : 4702) // Disable unreachable code warning for the last test // that is triggered when compiling as Win32|Release #endif diff --git a/third_party/clara.hpp b/third_party/clara.hpp index eb4c7275b1..6f661355aa 100644 --- a/third_party/clara.hpp +++ b/third_party/clara.hpp @@ -47,6 +47,8 @@ #include #include +#include + #ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 #endif @@ -379,7 +381,7 @@ namespace clara { namespace TextFlow { #include #include -#if !defined(CLARA_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#if !defined(CLARA_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) ) #define CLARA_PLATFORM_WINDOWS #endif From d8b5016fc9448aeb47ac75b3f303e70ed315f870 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Thu, 14 Apr 2022 17:56:19 +0430 Subject: [PATCH 4/7] Add MINGW32 compiler flag. (see #2094) --- src/catch2/internal/catch_compiler_capabilities.hpp | 6 +++++- src/catch2/internal/catch_debugger.cpp | 2 +- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_platform.hpp | 2 +- src/catch2/reporters/catch_reporter_junit.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 91c28baa76..314ce98b85 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -40,6 +40,10 @@ #define CATCH_COMPILER_MSC #endif +#if defined(__MINGW32__) +#define CATCH_COMPILER_MINGW32 +#endif + #ifdef __cplusplus # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) @@ -139,7 +143,7 @@ //////////////////////////////////////////////////////////////////////////////// // Not all Windows environments support SEH properly -#if defined(__MINGW32__) +#if defined(CATCH_COMPILER_MINGW32) # define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH #endif diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index a07cb788b5..31d777259e 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -108,7 +108,7 @@ return IsDebuggerPresent() != 0; } } -#elif defined(__MINGW32__) +#elif defined(CATCH_COMPILER_MINGW32) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); namespace Catch { bool isDebuggerActive() { diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index b16c14bab6..ca364d36f9 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -49,7 +49,7 @@ namespace Catch { #endif #elif defined(CATCH_COMPILER_MSC) #define CATCH_TRAP() __debugbreak() -#elif defined(__MINGW32__) +#elif defined(CATCH_COMPILER_MINGW32) extern "C" __declspec(dllimport) void __stdcall DebugBreak(); #define CATCH_TRAP() DebugBreak() #endif diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index 3416123ad6..158044e62d 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -24,7 +24,7 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) || defined(__MINGW32__) +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) || defined(CATCH_COMPILER_MINGW32) # define CATCH_PLATFORM_WINDOWS #endif diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index 0d71da6854..e9859e053a 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -29,7 +29,7 @@ namespace Catch { std::time(&rawtime); std::tm timeInfo = {}; -#if defined (CATCH_COMPILER_MSC) || defined (__MINGW32__) +#if defined (CATCH_COMPILER_MSC) || defined (CATCH_COMPILER_MINGW32) gmtime_s(&timeInfo, &rawtime); #else gmtime_r(&rawtime, &timeInfo); From cb49c62af9cdd5da6df5aadbc86c83b94fd807df Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Sat, 16 Apr 2022 01:13:02 +0430 Subject: [PATCH 5/7] Move macros to seprate header file. (see #2094) --- examples/231-Cfg-OutputStreams.cpp | 2 +- src/catch2/benchmark/catch_benchmark.hpp | 1 + src/catch2/benchmark/catch_optimizer.hpp | 2 +- .../benchmark/detail/catch_estimate_clock.hpp | 2 +- src/catch2/benchmark/detail/catch_stats.cpp | 1 + src/catch2/catch_all.hpp | 1 + src/catch2/catch_config.cpp | 2 +- src/catch2/catch_tag_alias_autoregistrar.hpp | 1 + src/catch2/catch_template_test_macros.hpp | 2 +- src/catch2/catch_test_case_info.hpp | 2 +- src/catch2/catch_test_spec.hpp | 2 +- src/catch2/catch_tostring.hpp | 1 + src/catch2/catch_translate_exception.hpp | 1 + src/catch2/internal/catch_clara.hpp | 2 +- src/catch2/internal/catch_combined_tu.cpp | 7 ++--- src/catch2/internal/catch_commandline.cpp | 1 + .../internal/catch_compiler_capabilities.hpp | 2 +- .../internal/catch_compiler_detections.hpp | 26 +++++++++++++++++++ .../catch_config_uncaught_exceptions.hpp | 2 +- src/catch2/internal/catch_console_colour.cpp | 2 +- .../internal/catch_container_nonmembers.hpp | 1 + src/catch2/internal/catch_debugger.cpp | 2 +- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_decomposer.hpp | 2 +- src/catch2/internal/catch_enforce.hpp | 1 + .../catch_exception_translator_registry.cpp | 1 + .../catch_fatal_condition_handler.cpp | 2 +- .../catch_fatal_condition_handler.hpp | 1 + src/catch2/internal/catch_main.cpp | 1 + src/catch2/internal/catch_output_redirect.cpp | 2 +- src/catch2/internal/catch_output_redirect.hpp | 1 + src/catch2/internal/catch_platform.hpp | 2 +- src/catch2/internal/catch_preprocessor.hpp | 2 +- .../catch_random_number_generator.cpp | 2 +- src/catch2/internal/catch_run_context.cpp | 1 + src/catch2/internal/catch_section.hpp | 1 + src/catch2/internal/catch_stream.hpp | 2 +- .../internal/catch_template_test_registry.hpp | 1 + .../internal/catch_test_case_tracker.cpp | 2 +- src/catch2/internal/catch_test_macro_impl.hpp | 2 +- src/catch2/internal/catch_test_registry.cpp | 1 + src/catch2/internal/catch_test_registry.hpp | 2 +- .../internal/catch_test_spec_parser.hpp | 2 +- src/catch2/internal/catch_to_string.hpp | 1 + .../catch_matchers_floating_point.cpp | 2 +- .../reporters/catch_reporter_combined_tu.cpp | 2 +- .../reporters/catch_reporter_console.cpp | 2 +- src/catch2/reporters/catch_reporter_junit.cpp | 2 +- .../reporters/catch_reporter_registrars.hpp | 1 + .../reporters/catch_reporter_teamcity.hpp | 2 +- src/catch2/reporters/catch_reporter_xml.cpp | 2 +- tests/ExtraTests/X02-DisabledMacros.cpp | 2 +- .../IntrospectiveTests/CmdLine.tests.cpp | 1 + .../IntrospectiveTests/Details.tests.cpp | 2 +- tests/SelfTest/TestRegistrations.cpp | 2 +- .../SelfTest/UsageTests/Compilation.tests.cpp | 2 +- tests/SelfTest/UsageTests/Condition.tests.cpp | 2 +- tests/SelfTest/UsageTests/Exception.tests.cpp | 2 +- .../SelfTest/UsageTests/Generators.tests.cpp | 2 +- tests/SelfTest/UsageTests/Matchers.tests.cpp | 2 +- .../UsageTests/MatchersRanges.tests.cpp | 2 +- tests/SelfTest/UsageTests/Message.tests.cpp | 2 +- tests/SelfTest/UsageTests/Misc.tests.cpp | 2 +- .../UsageTests/ToStringWhich.tests.cpp | 2 +- tests/SelfTest/UsageTests/Tricky.tests.cpp | 2 +- third_party/clara.hpp | 2 +- 66 files changed, 94 insertions(+), 47 deletions(-) create mode 100644 src/catch2/internal/catch_compiler_detections.hpp diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp index 5dccd54152..dd49cf2c4a 100644 --- a/examples/231-Cfg-OutputStreams.cpp +++ b/examples/231-Cfg-OutputStreams.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include class out_buff : public std::stringbuf { std::FILE* m_stream; diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index 28664b613e..28da328628 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/src/catch2/benchmark/catch_optimizer.hpp b/src/catch2/benchmark/catch_optimizer.hpp index 549b3e8561..0db1a7512b 100644 --- a/src/catch2/benchmark/catch_optimizer.hpp +++ b/src/catch2/benchmark/catch_optimizer.hpp @@ -10,7 +10,7 @@ #ifndef CATCH_OPTIMIZER_HPP_INCLUDED #define CATCH_OPTIMIZER_HPP_INCLUDED -#include +#include #if defined(CATCH_COMPILER_MSC) # include // atomic_thread_fence diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp index 0ae439f1a1..f37a239cce 100644 --- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp +++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 0f94d5b732..deba9a0efa 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index b082b7669f..77dd00c325 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 852f0e463f..b96cf46a69 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/catch2/catch_tag_alias_autoregistrar.hpp b/src/catch2/catch_tag_alias_autoregistrar.hpp index c742bcd3bc..ee73c7a583 100644 --- a/src/catch2/catch_tag_alias_autoregistrar.hpp +++ b/src/catch2/catch_tag_alias_autoregistrar.hpp @@ -9,6 +9,7 @@ #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED #include +#include #include #include diff --git a/src/catch2/catch_template_test_macros.hpp b/src/catch2/catch_template_test_macros.hpp index df30ddd0e8..e90d373011 100644 --- a/src/catch2/catch_template_test_macros.hpp +++ b/src/catch2/catch_template_test_macros.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED #define CATCH_TEMPLATE_TEST_MACROS_HPP_INCLUDED -#include +#include // We need this suppression to leak, because it took until GCC 10 // for the front end to handle local suppression via _Pragma properly diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 5477ccc2f1..0b279cb7a8 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED -#include +#include #include #include #include diff --git a/src/catch2/catch_test_spec.hpp b/src/catch2/catch_test_spec.hpp index 9f1556903b..8cb89c91c9 100644 --- a/src/catch2/catch_test_spec.hpp +++ b/src/catch2/catch_test_spec.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_TEST_SPEC_HPP_INCLUDED #define CATCH_TEST_SPEC_HPP_INCLUDED -#include +#include #ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index b6d416c10a..92c799f1f5 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp index dfd95cd696..f4dc05998e 100644 --- a/src/catch2/catch_translate_exception.hpp +++ b/src/catch2/catch_translate_exception.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 3010225125..add00c0dba 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -29,7 +29,7 @@ # endif #endif -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_combined_tu.cpp b/src/catch2/internal/catch_combined_tu.cpp index 601ac8e729..71af4cae09 100644 --- a/src/catch2/internal/catch_combined_tu.cpp +++ b/src/catch2/internal/catch_combined_tu.cpp @@ -24,6 +24,7 @@ #include #include +#include #include namespace Catch { @@ -45,7 +46,7 @@ namespace Catch { ////////////////////////////////////////// #include -#include +#include #include namespace Catch { @@ -74,7 +75,7 @@ namespace Catch { // vvv formerly catch_uncaught_exceptions.cpp vvv // //////////////////////////////////////////////////// -#include +#include #include #include @@ -130,7 +131,7 @@ namespace Catch { // vvv formerly catch_startup_exception_registry.cpp vvv // /////////////////////////////////////////////////////////// #include -#include +#include namespace Catch { #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp index d16e7e37c6..fb2275d169 100644 --- a/src/catch2/internal/catch_commandline.cpp +++ b/src/catch2/internal/catch_commandline.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 314ce98b85..16888c74ec 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -24,7 +24,7 @@ // Many features, at point of detection, define an _INTERNAL_ macro, so they // can be combined, en-mass, with the _NO_ forms later. -#include +#include #include #include diff --git a/src/catch2/internal/catch_compiler_detections.hpp b/src/catch2/internal/catch_compiler_detections.hpp new file mode 100644 index 0000000000..f30bc446df --- /dev/null +++ b/src/catch2/internal/catch_compiler_detections.hpp @@ -0,0 +1,26 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef CATCH_COMPILER_DETECTIONS_HPP_INCLUDED +#define CATCH_COMPILER_DETECTIONS_HPP_INCLUDED + +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +#define CATCH_COMPILER_GCC +#endif + +#if defined(__clang__) +#define CATCH_COMPILER_CLANG +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#define CATCH_COMPILER_MSC +#endif + +#if defined(__MINGW32__) +#define CATCH_COMPILER_MINGW32 +#endif + +#endif // CATCH_COMPILER_DETECTIONS_HPP_INCLUDED \ No newline at end of file diff --git a/src/catch2/internal/catch_config_uncaught_exceptions.hpp b/src/catch2/internal/catch_config_uncaught_exceptions.hpp index beabd31da4..d3dc37a1ba 100644 --- a/src/catch2/internal/catch_config_uncaught_exceptions.hpp +++ b/src/catch2/internal/catch_config_uncaught_exceptions.hpp @@ -17,7 +17,7 @@ #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED -#include +#include #if defined(CATCH_COMPILER_MSC) # if _MSC_VER >= 1900 // Visual Studio 2015 or newer diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index 54ea3a7046..ae22d67b2d 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -11,7 +11,6 @@ #endif -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include diff --git a/src/catch2/internal/catch_container_nonmembers.hpp b/src/catch2/internal/catch_container_nonmembers.hpp index b828415c5e..7e9f8c128d 100644 --- a/src/catch2/internal/catch_container_nonmembers.hpp +++ b/src/catch2/internal/catch_container_nonmembers.hpp @@ -9,6 +9,7 @@ #define CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED #include +#include #include #include diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index 31d777259e..9b51b1f327 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index ca364d36f9..e89756f006 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_DEBUGGER_HPP_INCLUDED #define CATCH_DEBUGGER_HPP_INCLUDED -#include +#include #include namespace Catch { diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 68390e72a9..73772ec6fb 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -9,7 +9,7 @@ #define CATCH_DECOMPOSER_HPP_INCLUDED #include -#include +#include #include #include diff --git a/src/catch2/internal/catch_enforce.hpp b/src/catch2/internal/catch_enforce.hpp index 3f81ef1a03..a12de27c74 100644 --- a/src/catch2/internal/catch_enforce.hpp +++ b/src/catch2/internal/catch_enforce.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/catch2/internal/catch_exception_translator_registry.cpp b/src/catch2/internal/catch_exception_translator_registry.cpp index acddea6ec9..603d00c207 100644 --- a/src/catch2/internal/catch_exception_translator_registry.cpp +++ b/src/catch2/internal/catch_exception_translator_registry.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_fatal_condition_handler.cpp b/src/catch2/internal/catch_fatal_condition_handler.cpp index 754d643bc4..05d4165c42 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.cpp +++ b/src/catch2/internal/catch_fatal_condition_handler.cpp @@ -26,7 +26,7 @@ #include -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_fatal_condition_handler.hpp b/src/catch2/internal/catch_fatal_condition_handler.hpp index 389dab5d4c..1d5d2196f6 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.hpp +++ b/src/catch2/internal/catch_fatal_condition_handler.hpp @@ -10,6 +10,7 @@ #include #include +#include #include diff --git a/src/catch2/internal/catch_main.cpp b/src/catch2/internal/catch_main.cpp index f523bbfa36..373d838f4f 100644 --- a/src/catch2/internal/catch_main.cpp +++ b/src/catch2/internal/catch_main.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 235cc07ac5..a6bae64ff5 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index 1ccce57e8d..021b6d5e85 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index 158044e62d..ba723765e1 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_PLATFORM_HPP_INCLUDED #define CATCH_PLATFORM_HPP_INCLUDED -#include +#include // See e.g.: // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 80023a1896..3aac18df4b 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_PREPROCESSOR_HPP_INCLUDED #define CATCH_PREPROCESSOR_HPP_INCLUDED -#include +#include #if defined(CATCH_COMPILER_GCC) // We need to silence "empty __VA_ARGS__ warning", and using just _Pragma does not work diff --git a/src/catch2/internal/catch_random_number_generator.cpp b/src/catch2/internal/catch_random_number_generator.cpp index e154446dd8..75d91e38e0 100644 --- a/src/catch2/internal/catch_random_number_generator.cpp +++ b/src/catch2/internal/catch_random_number_generator.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include namespace Catch { diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 6a32cdc161..40836a6106 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index 2e72923c3a..f6b3ed8066 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -9,6 +9,7 @@ #define CATCH_SECTION_HPP_INCLUDED #include +#include #include #include #include diff --git a/src/catch2/internal/catch_stream.hpp b/src/catch2/internal/catch_stream.hpp index a3397a8633..cdc509964d 100644 --- a/src/catch2/internal/catch_stream.hpp +++ b/src/catch2/internal/catch_stream.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_STREAM_HPP_INCLUDED #define CATCH_STREAM_HPP_INCLUDED -#include +#include #include #include diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index e45ad9524b..7eee911840 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp index 7fd7fc55e6..192e4b48e5 100644 --- a/src/catch2/internal/catch_test_case_tracker.cpp +++ b/src/catch2/internal/catch_test_case_tracker.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp index 55a6534b11..c49d1c597a 100644 --- a/src/catch2/internal/catch_test_macro_impl.hpp +++ b/src/catch2/internal/catch_test_macro_impl.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index faadb101b6..5fa87b5312 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 1b0d099f57..cd28dd6662 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED #define CATCH_TEST_REGISTRY_HPP_INCLUDED -#include +#include #include #include #include diff --git a/src/catch2/internal/catch_test_spec_parser.hpp b/src/catch2/internal/catch_test_spec_parser.hpp index 1a216be3f2..b4a52f8556 100644 --- a/src/catch2/internal/catch_test_spec_parser.hpp +++ b/src/catch2/internal/catch_test_spec_parser.hpp @@ -13,7 +13,7 @@ #pragma clang diagnostic ignored "-Wpadded" #endif -#include +#include #include #include diff --git a/src/catch2/internal/catch_to_string.hpp b/src/catch2/internal/catch_to_string.hpp index d8ff35cfc5..069ca72c20 100644 --- a/src/catch2/internal/catch_to_string.hpp +++ b/src/catch2/internal/catch_to_string.hpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace Catch { diff --git a/src/catch2/matchers/catch_matchers_floating_point.cpp b/src/catch2/matchers/catch_matchers_floating_point.cpp index f88548472d..66dfb6632f 100644 --- a/src/catch2/matchers/catch_matchers_floating_point.cpp +++ b/src/catch2/matchers/catch_matchers_floating_point.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp index fdd1064919..6cfe78bacb 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index 20d7c1458c..19a48a78fc 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index e9859e053a..48dbd300bc 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/catch2/reporters/catch_reporter_registrars.hpp b/src/catch2/reporters/catch_reporter_registrars.hpp index 31ecb08043..49f49f4576 100644 --- a/src/catch2/reporters/catch_reporter_registrars.hpp +++ b/src/catch2/reporters/catch_reporter_registrars.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp index b15c04a77a..d8a3730e2e 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.hpp +++ b/src/catch2/reporters/catch_reporter_teamcity.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED -#include +#include #include #include diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index e34af221bb..d62f2711a8 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp index d2d8f1e5ae..b236b22b1e 100644 --- a/tests/ExtraTests/X02-DisabledMacros.cpp +++ b/tests/ExtraTests/X02-DisabledMacros.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index e7b0c9c163..c910664cf8 100644 --- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace { diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index d2a290e22a..5bc3d4f36e 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 -#include +#include #include #include #include diff --git a/tests/SelfTest/TestRegistrations.cpp b/tests/SelfTest/TestRegistrations.cpp index d5d9b5643d..8be2c8cd80 100644 --- a/tests/SelfTest/TestRegistrations.cpp +++ b/tests/SelfTest/TestRegistrations.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index 5b57e098e6..eb9db8f4e4 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -12,7 +12,7 @@ // in a different namespace. #include -#include +#include namespace foo { struct helper_1403 { diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index edd122d4ce..de0857b202 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 -#include +#include #ifdef CATCH_COMPILER_CLANG # pragma clang diagnostic push diff --git a/tests/SelfTest/UsageTests/Exception.tests.cpp b/tests/SelfTest/UsageTests/Exception.tests.cpp index 9e8b731464..bcaa21dbcc 100644 --- a/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp index 30ef24a4f5..e04371ebbe 100644 --- a/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include #include diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index f70e5602cf..66a418f4cb 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp index 42a6f30ca7..54b7c4ebde 100644 --- a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +++ b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include #include diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 5a7dd35503..cbd700502a 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) { diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp index 829f50860b..6001fbf5eb 100644 --- a/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp b/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp index 4f78633811..d3ef2b4bc3 100644 --- a/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp +++ b/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp @@ -8,7 +8,7 @@ #include -#include +#include #if defined(CATCH_COMPILER_GCC) // This has to be left enabled until end of the TU, because the GCC diff --git a/tests/SelfTest/UsageTests/Tricky.tests.cpp b/tests/SelfTest/UsageTests/Tricky.tests.cpp index 5108c6a5c7..68276f47c0 100644 --- a/tests/SelfTest/UsageTests/Tricky.tests.cpp +++ b/tests/SelfTest/UsageTests/Tricky.tests.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 -#include +#include #ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic ignored "-Wpadded" diff --git a/third_party/clara.hpp b/third_party/clara.hpp index 6f661355aa..ca513ca020 100644 --- a/third_party/clara.hpp +++ b/third_party/clara.hpp @@ -47,7 +47,7 @@ #include #include -#include +#include #ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 From eed97e99a4f1117159a001ce50a929b9c84a0930 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Sat, 16 Apr 2022 02:47:54 +0430 Subject: [PATCH 6/7] Remove unnecessary includes. (see #2094) --- src/catch2/benchmark/catch_benchmark.hpp | 1 - src/catch2/benchmark/detail/catch_stats.cpp | 1 - src/catch2/catch_tag_alias_autoregistrar.hpp | 1 - src/catch2/catch_translate_exception.hpp | 1 - src/catch2/internal/catch_clara.hpp | 3 ++- src/catch2/internal/catch_combined_tu.cpp | 4 ---- src/catch2/internal/catch_commandline.cpp | 1 - .../internal/catch_compiler_capabilities.hpp | 16 ---------------- src/catch2/internal/catch_console_colour.cpp | 5 +++-- src/catch2/internal/catch_enforce.hpp | 1 - .../catch_exception_translator_registry.cpp | 1 - .../internal/catch_fatal_condition_handler.hpp | 1 - src/catch2/internal/catch_main.cpp | 1 - src/catch2/internal/catch_run_context.cpp | 1 - src/catch2/internal/catch_section.hpp | 1 - src/catch2/internal/catch_source_line_info.cpp | 2 ++ src/catch2/internal/catch_test_registry.cpp | 1 - src/catch2/internal/catch_to_string.hpp | 1 - .../reporters/catch_reporter_registrars.hpp | 1 - .../IntrospectiveTests/CmdLine.tests.cpp | 1 - 20 files changed, 7 insertions(+), 38 deletions(-) diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index 28da328628..28664b613e 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 8f13f59a2a..10511d4c95 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/catch2/catch_tag_alias_autoregistrar.hpp b/src/catch2/catch_tag_alias_autoregistrar.hpp index ee73c7a583..c742bcd3bc 100644 --- a/src/catch2/catch_tag_alias_autoregistrar.hpp +++ b/src/catch2/catch_tag_alias_autoregistrar.hpp @@ -9,7 +9,6 @@ #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED #include -#include #include #include diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp index f4dc05998e..dfd95cd696 100644 --- a/src/catch2/catch_translate_exception.hpp +++ b/src/catch2/catch_translate_exception.hpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 6e3138aecb..79f21adf71 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -8,6 +8,8 @@ #ifndef CATCH_CLARA_HPP_INCLUDED #define CATCH_CLARA_HPP_INCLUDED +#include + #if defined( CATCH_COMPILER_CLANG ) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wweak-vtables" @@ -29,7 +31,6 @@ # endif #endif -#include #include #include #include diff --git a/src/catch2/internal/catch_combined_tu.cpp b/src/catch2/internal/catch_combined_tu.cpp index 71af4cae09..bc6043f5d0 100644 --- a/src/catch2/internal/catch_combined_tu.cpp +++ b/src/catch2/internal/catch_combined_tu.cpp @@ -24,7 +24,6 @@ #include #include -#include #include namespace Catch { @@ -46,7 +45,6 @@ namespace Catch { ////////////////////////////////////////// #include -#include #include namespace Catch { @@ -75,7 +73,6 @@ namespace Catch { // vvv formerly catch_uncaught_exceptions.cpp vvv // //////////////////////////////////////////////////// -#include #include #include @@ -131,7 +128,6 @@ namespace Catch { // vvv formerly catch_startup_exception_registry.cpp vvv // /////////////////////////////////////////////////////////// #include -#include namespace Catch { #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp index 81787aa965..59b06de9f3 100644 --- a/src/catch2/internal/catch_commandline.cpp +++ b/src/catch2/internal/catch_commandline.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 16888c74ec..2f9ee3390d 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -28,22 +28,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -#define CATCH_COMPILER_GCC -#endif - -#if defined(__clang__) -#define CATCH_COMPILER_CLANG -#endif - -#if defined(_MSC_VER) && !defined(__clang__) -#define CATCH_COMPILER_MSC -#endif - -#if defined(__MINGW32__) -#define CATCH_COMPILER_MINGW32 -#endif - #ifdef __cplusplus # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index e2a175f173..25af95857b 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -4,6 +4,9 @@ // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) +#include +#include + // SPDX-License-Identifier: BSL-1.0 #if defined(CATCH_COMPILER_CLANG) # pragma clang diagnostic push @@ -11,7 +14,6 @@ #endif -#include #include #include #include @@ -22,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/src/catch2/internal/catch_enforce.hpp b/src/catch2/internal/catch_enforce.hpp index a12de27c74..3f81ef1a03 100644 --- a/src/catch2/internal/catch_enforce.hpp +++ b/src/catch2/internal/catch_enforce.hpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/catch2/internal/catch_exception_translator_registry.cpp b/src/catch2/internal/catch_exception_translator_registry.cpp index 603d00c207..acddea6ec9 100644 --- a/src/catch2/internal/catch_exception_translator_registry.cpp +++ b/src/catch2/internal/catch_exception_translator_registry.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_fatal_condition_handler.hpp b/src/catch2/internal/catch_fatal_condition_handler.hpp index 1d5d2196f6..389dab5d4c 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.hpp +++ b/src/catch2/internal/catch_fatal_condition_handler.hpp @@ -10,7 +10,6 @@ #include #include -#include #include diff --git a/src/catch2/internal/catch_main.cpp b/src/catch2/internal/catch_main.cpp index 373d838f4f..f523bbfa36 100644 --- a/src/catch2/internal/catch_main.cpp +++ b/src/catch2/internal/catch_main.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 40836a6106..6a32cdc161 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index f6b3ed8066..2e72923c3a 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -9,7 +9,6 @@ #define CATCH_SECTION_HPP_INCLUDED #include -#include #include #include #include diff --git a/src/catch2/internal/catch_source_line_info.cpp b/src/catch2/internal/catch_source_line_info.cpp index 1f8c5966aa..53c4e5c1a3 100644 --- a/src/catch2/internal/catch_source_line_info.cpp +++ b/src/catch2/internal/catch_source_line_info.cpp @@ -10,6 +10,8 @@ #include #include +#include + namespace Catch { bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index 5fa87b5312..faadb101b6 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_to_string.hpp b/src/catch2/internal/catch_to_string.hpp index 069ca72c20..d8ff35cfc5 100644 --- a/src/catch2/internal/catch_to_string.hpp +++ b/src/catch2/internal/catch_to_string.hpp @@ -11,7 +11,6 @@ #include #include -#include #include namespace Catch { diff --git a/src/catch2/reporters/catch_reporter_registrars.hpp b/src/catch2/reporters/catch_reporter_registrars.hpp index 49f49f4576..31ecb08043 100644 --- a/src/catch2/reporters/catch_reporter_registrars.hpp +++ b/src/catch2/reporters/catch_reporter_registrars.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index c910664cf8..e7b0c9c163 100644 --- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -16,7 +16,6 @@ #include #include #include -#include namespace { From 56d04d2c5df59b91e316f5aabfe9d9f43d557044 Mon Sep 17 00:00:00 2001 From: HoseynHeydari Date: Mon, 18 Apr 2022 01:48:32 +0430 Subject: [PATCH 7/7] Move compiler detection header beffore using CATCH_COMPILER_CLANG macro. (see #2094) --- src/catch2/internal/catch_compiler_capabilities.hpp | 2 +- src/catch2/internal/catch_compiler_detections.hpp | 2 +- src/catch2/internal/catch_config_uncaught_exceptions.hpp | 2 +- src/catch2/internal/catch_container_nonmembers.hpp | 2 +- src/catch2/internal/catch_debugger.cpp | 2 +- src/catch2/internal/catch_debugger.hpp | 2 +- src/catch2/internal/catch_decomposer.hpp | 4 ++-- src/catch2/internal/catch_output_redirect.cpp | 8 ++++---- src/catch2/internal/catch_output_redirect.hpp | 2 +- src/catch2/internal/catch_platform.hpp | 2 +- src/catch2/internal/catch_random_number_generator.cpp | 4 ++-- src/catch2/internal/catch_test_spec_parser.hpp | 3 ++- 12 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index 2f9ee3390d..67611863ed 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -156,7 +156,7 @@ //////////////////////////////////////////////////////////////////////////////// // Visual C++ -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) diff --git a/src/catch2/internal/catch_compiler_detections.hpp b/src/catch2/internal/catch_compiler_detections.hpp index f30bc446df..717f1c36e6 100644 --- a/src/catch2/internal/catch_compiler_detections.hpp +++ b/src/catch2/internal/catch_compiler_detections.hpp @@ -16,7 +16,7 @@ #endif #if defined(_MSC_VER) && !defined(__clang__) -#define CATCH_COMPILER_MSC +#define CATCH_COMPILER_MSVC #endif #if defined(__MINGW32__) diff --git a/src/catch2/internal/catch_config_uncaught_exceptions.hpp b/src/catch2/internal/catch_config_uncaught_exceptions.hpp index d3dc37a1ba..2f62324627 100644 --- a/src/catch2/internal/catch_config_uncaught_exceptions.hpp +++ b/src/catch2/internal/catch_config_uncaught_exceptions.hpp @@ -19,7 +19,7 @@ #include -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) # if _MSC_VER >= 1900 // Visual Studio 2015 or newer # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS # endif diff --git a/src/catch2/internal/catch_container_nonmembers.hpp b/src/catch2/internal/catch_container_nonmembers.hpp index 7e9f8c128d..6af00e0d9b 100644 --- a/src/catch2/internal/catch_container_nonmembers.hpp +++ b/src/catch2/internal/catch_container_nonmembers.hpp @@ -18,7 +18,7 @@ // for C++14 or C++ libraries with incomplete support. // We also have to handle that MSVC std lib will happily provide these // under older standards. -#if defined(CATCH_CPP17_OR_GREATER) || defined(CATCH_COMPILER_MSC) +#if defined(CATCH_CPP17_OR_GREATER) || defined(CATCH_COMPILER_MSVC) // We are already using this header either way, so there shouldn't // be much additional overhead in including it to get the feature diff --git a/src/catch2/internal/catch_debugger.cpp b/src/catch2/internal/catch_debugger.cpp index f55adbceb0..9934dc08a8 100644 --- a/src/catch2/internal/catch_debugger.cpp +++ b/src/catch2/internal/catch_debugger.cpp @@ -101,7 +101,7 @@ return false; } } // namespace Catch -#elif defined(CATCH_COMPILER_MSC) +#elif defined(CATCH_COMPILER_MSVC) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); namespace Catch { bool isDebuggerActive() { diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index e89756f006..d880bc7b36 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -47,7 +47,7 @@ namespace Catch { #define CATCH_TRAP() raise(SIGTRAP) #endif -#elif defined(CATCH_COMPILER_MSC) +#elif defined(CATCH_COMPILER_MSVC) #define CATCH_TRAP() __debugbreak() #elif defined(CATCH_COMPILER_MINGW32) extern "C" __declspec(dllimport) void __stdcall DebugBreak(); diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 73772ec6fb..7546322c2d 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -15,7 +15,7 @@ #include -#ifdef CATCH_COMPILER_MSC +#ifdef CATCH_COMPILER_MSVC #pragma warning(push) #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #pragma warning(disable:4018) // more "signed/unsigned mismatch" @@ -257,7 +257,7 @@ namespace Catch { } // end namespace Catch -#ifdef CATCH_COMPILER_MSC +#ifdef CATCH_COMPILER_MSVC #pragma warning(pop) #endif #ifdef CATCH_COMPILER_CLANG diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 6d1569a6f3..2ea6920676 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -16,7 +16,7 @@ #include #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) #include //_dup and _dup2 #define dup _dup #define dup2 _dup2 @@ -62,7 +62,7 @@ namespace Catch { #if defined(CATCH_CONFIG_NEW_CAPTURE) -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) TempFile::TempFile() { if (tmpnam_s(m_buffer)) { CATCH_RUNTIME_ERROR("Could not get a temp filename"); @@ -90,7 +90,7 @@ namespace Catch { std::fclose(m_file); // We manually create the file on Windows only, on Linux // it will be autodeleted -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) std::remove(m_buffer); #endif } @@ -140,7 +140,7 @@ namespace Catch { } // namespace Catch #if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) #undef dup #undef dup2 #undef fileno diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index 2eaa0135c7..2654e5ebe2 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -86,7 +86,7 @@ namespace Catch { private: std::FILE* m_file = nullptr; - #if defined(CATCH_COMPILER_MSC) + #if defined(CATCH_COMPILER_MSVC) char m_buffer[L_tmpnam] = { 0 }; #endif }; diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index ba723765e1..fe56141e50 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -24,7 +24,7 @@ #elif defined(linux) || defined(__linux) || defined(__linux__) # define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSC) || defined(CATCH_COMPILER_MINGW32) +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(CATCH_COMPILER_MSVC) || defined(CATCH_COMPILER_MINGW32) # define CATCH_PLATFORM_WINDOWS #endif diff --git a/src/catch2/internal/catch_random_number_generator.cpp b/src/catch2/internal/catch_random_number_generator.cpp index 75d91e38e0..0fa71fb047 100644 --- a/src/catch2/internal/catch_random_number_generator.cpp +++ b/src/catch2/internal/catch_random_number_generator.cpp @@ -13,7 +13,7 @@ namespace Catch { namespace { -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) #pragma warning(push) #pragma warning(disable:4146) // we negate uint32 during the rotate #endif @@ -24,7 +24,7 @@ namespace { return (val >> count) | (val << (-count & mask)); } -#if defined(CATCH_COMPILER_MSC) +#if defined(CATCH_COMPILER_MSVC) #pragma warning(pop) #endif diff --git a/src/catch2/internal/catch_test_spec_parser.hpp b/src/catch2/internal/catch_test_spec_parser.hpp index b4a52f8556..d7f235c3ca 100644 --- a/src/catch2/internal/catch_test_spec_parser.hpp +++ b/src/catch2/internal/catch_test_spec_parser.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED +#include + #ifdef CATCH_COMPILER_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #endif -#include #include #include