Add clang compiler flag. (see #2094)

This commit is contained in:
HoseynHeydari 2022-04-14 16:46:59 +04:30
parent bd0ee6adbe
commit c665fd7f50
25 changed files with 80 additions and 49 deletions

View File

@ -10,6 +10,8 @@
#include <sstream> #include <sstream>
#include <cstdio> #include <cstdio>
#include <catch2/internal/catch_compiler_capabilities.hpp>
class out_buff : public std::stringbuf { class out_buff : public std::stringbuf {
std::FILE* m_stream; std::FILE* m_stream;
public: public:
@ -31,7 +33,7 @@ public:
out_buff::~out_buff() { pubsync(); } 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 #pragma clang diagnostic ignored "-Wexit-time-destructors" // static variables in cout/cerr/clog
#endif #endif

View File

@ -21,7 +21,7 @@
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
#if defined(CATCH_COMPILER_GCC) || defined(__clang__) #if defined(CATCH_COMPILER_GCC) || defined(CATCH_COMPILER_CLANG)
template <typename T> template <typename T>
inline void keep_memory(T* p) { inline void keep_memory(T* p) {
asm volatile("" : : "g"(p) : "memory"); asm volatile("" : : "g"(p) : "memory");

View File

@ -16,6 +16,7 @@
#include <catch2/benchmark/detail/catch_measure.hpp> #include <catch2/benchmark/detail/catch_measure.hpp>
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp> #include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
#include <catch2/benchmark/catch_clock.hpp> #include <catch2/benchmark/catch_clock.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#include <algorithm> #include <algorithm>
@ -95,12 +96,12 @@ namespace Catch {
template <typename Clock> template <typename Clock>
Environment<FloatDuration<Clock>> measure_environment() { Environment<FloatDuration<Clock>> measure_environment() {
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors" # pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif #endif
static Catch::Detail::unique_ptr<Environment<FloatDuration<Clock>>> env; static Catch::Detail::unique_ptr<Environment<FloatDuration<Clock>>> env;
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif
if (env) { if (env) {

View File

@ -8,6 +8,7 @@
#ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED
#define CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_source_line_info.hpp> #include <catch2/internal/catch_source_line_info.hpp>
#include <catch2/internal/catch_noncopyable.hpp> #include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
@ -18,7 +19,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif
@ -123,7 +124,7 @@ namespace Catch {
SourceLineInfo const& lineInfo ); SourceLineInfo const& lineInfo );
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -8,7 +8,9 @@
#ifndef CATCH_TEST_SPEC_HPP_INCLUDED #ifndef CATCH_TEST_SPEC_HPP_INCLUDED
#define CATCH_TEST_SPEC_HPP_INCLUDED #define CATCH_TEST_SPEC_HPP_INCLUDED
#ifdef __clang__ #include <catch2/internal/catch_compiler_capabilities.hpp>
#ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif
@ -81,7 +83,7 @@ namespace Catch {
}; };
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -8,7 +8,7 @@
#ifndef CATCH_CLARA_HPP_INCLUDED #ifndef CATCH_CLARA_HPP_INCLUDED
#define CATCH_CLARA_HPP_INCLUDED #define CATCH_CLARA_HPP_INCLUDED
#if defined( __clang__ ) #if defined( CATCH_COMPILER_CLANG )
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wshadow" # pragma clang diagnostic ignored "-Wshadow"
@ -29,6 +29,7 @@
# endif # endif
#endif #endif
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_move_and_forward.hpp> #include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_noncopyable.hpp> #include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_void_type.hpp> #include <catch2/internal/catch_void_type.hpp>
@ -698,7 +699,7 @@ namespace Catch {
} // namespace Clara } // namespace Clara
} // namespace Catch } // namespace Catch
#if defined( __clang__ ) #if defined( CATCH_COMPILER_CLANG )
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -24,6 +24,7 @@
// Many features, at point of detection, define an _INTERNAL_ macro, so they // Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later. // can be combined, en-mass, with the _NO_ forms later.
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_platform.hpp> #include <catch2/internal/catch_platform.hpp>
#include <catch2/catch_user_config.hpp> #include <catch2/catch_user_config.hpp>
@ -31,6 +32,10 @@
#define CATCH_COMPILER_GCC #define CATCH_COMPILER_GCC
#endif #endif
#if defined(__clang__) && !defined(_MSC_VER)
#define CATCH_COMPILER_CLANG
#endif
#ifdef __cplusplus #ifdef __cplusplus
# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) # if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
@ -61,7 +66,7 @@
#endif #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_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )
@ -103,7 +108,7 @@
# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ # define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
_Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) _Pragma( "clang diagnostic ignored \"-Wunused-template\"" )
#endif // __clang__ #endif // CATCH_COMPILER_CLANG
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -5,12 +5,13 @@
// https://www.boost.org/LICENSE_1_0.txt) // https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors" # pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif #endif
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_console_colour.hpp> #include <catch2/internal/catch_console_colour.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_errno_guard.hpp> #include <catch2/internal/catch_errno_guard.hpp>
@ -277,7 +278,7 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -9,6 +9,7 @@
#define CATCH_DECOMPOSER_HPP_INCLUDED #define CATCH_DECOMPOSER_HPP_INCLUDED
#include <catch2/catch_tostring.hpp> #include <catch2/catch_tostring.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_meta.hpp> #include <catch2/internal/catch_meta.hpp>
@ -23,7 +24,7 @@
#pragma warning(disable:4800) // Forcing result to true or false #pragma warning(disable:4800) // Forcing result to true or false
#endif #endif
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-compare" # pragma clang diagnostic ignored "-Wsign-compare"
#elif defined CATCH_COMPILER_GCC #elif defined CATCH_COMPILER_GCC
@ -259,7 +260,7 @@ namespace Catch {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic pop # pragma clang diagnostic pop
#elif defined CATCH_COMPILER_GCC #elif defined CATCH_COMPILER_GCC
# pragma GCC diagnostic pop # pragma GCC diagnostic pop

View File

@ -7,6 +7,7 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/internal/catch_test_case_tracker.hpp> #include <catch2/internal/catch_test_case_tracker.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_move_and_forward.hpp> #include <catch2/internal/catch_move_and_forward.hpp>
@ -14,7 +15,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors" # pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif #endif
@ -245,6 +246,6 @@ namespace TestCaseTracking {
} // namespace Catch } // namespace Catch
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -8,11 +8,12 @@
#ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
#define 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 push
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <vector> #include <vector>
@ -75,7 +76,7 @@ namespace Catch {
} // namespace Catch } // namespace Catch
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -6,6 +6,7 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/matchers/catch_matchers_floating_point.hpp> #include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_polyfills.hpp> #include <catch2/internal/catch_polyfills.hpp>
#include <catch2/internal/catch_to_string.hpp> #include <catch2/internal/catch_to_string.hpp>
@ -115,7 +116,7 @@ namespace Detail {
"IEEE-754 compatible floating point representation" ); "IEEE-754 compatible floating point representation" );
} }
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic push #pragma clang diagnostic push
// Clang <3.5 reports on the default branch in the switch below // Clang <3.5 reports on the default branch in the switch below
#pragma clang diagnostic ignored "-Wunreachable-code" #pragma clang diagnostic ignored "-Wunreachable-code"
@ -132,7 +133,7 @@ namespace Detail {
} }
} }
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -9,6 +9,7 @@
#include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_console_colour.hpp> #include <catch2/internal/catch_console_colour.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_version.hpp> #include <catch2/catch_version.hpp>
@ -28,7 +29,7 @@
// Note that 4062 (not all labels are handled and default is missing) is enabled // Note that 4062 (not all labels are handled and default is missing) is enabled
#endif #endif
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic push # pragma clang diagnostic push
// For simplicity, benchmarking-only helpers are always enabled // For simplicity, benchmarking-only helpers are always enabled
# pragma clang diagnostic ignored "-Wunused-function" # pragma clang diagnostic ignored "-Wunused-function"
@ -714,6 +715,6 @@ void ConsoleReporter::printTestFilters() {
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -8,12 +8,13 @@
#ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #ifndef CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #define CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/reporters/catch_reporter_streaming_base.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_timer.hpp> #include <catch2/catch_timer.hpp>
#include <cstring> #include <cstring>
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
#endif #endif
@ -59,7 +60,7 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -14,6 +14,7 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp> #include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/matchers/catch_matchers.hpp> #include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_predicate.hpp> #include <catch2/matchers/catch_matchers_predicate.hpp>
@ -28,7 +29,7 @@ struct foo {
} }
}; };
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wglobal-constructors"
#endif #endif
@ -36,7 +37,7 @@ struct foo {
foo f; foo f;
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
// The test is unused since the registration is disabled // The test is unused since the registration is disabled
#pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wunused-function"
#endif #endif
@ -60,6 +61,6 @@ TEST_CASE( "Disabled Macros" ) {
BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); }; BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); };
} }
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -7,9 +7,10 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_tag_alias_autoregistrar.hpp> #include <catch2/catch_tag_alias_autoregistrar.hpp>
#include <catch2/reporters/catch_reporter_event_listener.hpp>
#include <catch2/internal/catch_enforce.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_enforce.hpp>
#include <catch2/reporters/catch_reporter_event_listener.hpp>
#include <catch2/reporters/catch_reporter_registrars.hpp> #include <catch2/reporters/catch_reporter_registrars.hpp>
@ -17,7 +18,7 @@
CATCH_REGISTER_TAG_ALIAS("[@nhf]", "[failing]~[.]") CATCH_REGISTER_TAG_ALIAS("[@nhf]", "[failing]~[.]")
CATCH_REGISTER_TAG_ALIAS("[@tricky]", "[tricky]~[.]") CATCH_REGISTER_TAG_ALIAS("[@tricky]", "[tricky]~[.]")
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wc++98-compat" # pragma clang diagnostic ignored "-Wc++98-compat"

View File

@ -77,7 +77,7 @@ struct B : private A {
bool operator==(int) const { return true; } bool operator==(int) const { return true; }
}; };
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wunused-function"
#endif #endif
@ -91,7 +91,7 @@ B f();
std::ostream g(); std::ostream g();
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -6,7 +6,9 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#ifdef __clang__ #include <catch2/internal/catch_compiler_capabilities.hpp>
#ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
// Wdouble-promotion is not supported until 3.8 // 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" ); CHECK( data.str_hello <= "a" );
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -8,6 +8,7 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/catch_translate_exception.hpp> #include <catch2/catch_translate_exception.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/matchers/catch_matchers_string.hpp> #include <catch2/matchers/catch_matchers_string.hpp>
#include <string> #include <string>
@ -16,7 +17,7 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4702) // Unreachable code -- unconditional throws and so on #pragma warning(disable:4702) // Unreachable code -- unconditional throws and so on
#endif #endif
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables" #pragma clang diagnostic ignored "-Wweak-vtables"
#pragma clang diagnostic ignored "-Wmissing-noreturn" #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 #pragma clang diagnostic pop
#endif #endif

View File

@ -7,6 +7,7 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/generators/catch_generator_exception.hpp> #include <catch2/generators/catch_generator_exception.hpp>
#include <catch2/generators/catch_generators_adapters.hpp> #include <catch2/generators/catch_generators_adapters.hpp>
#include <catch2/generators/catch_generators_random.hpp> #include <catch2/generators/catch_generators_random.hpp>
@ -235,7 +236,7 @@ namespace {
} }
} }
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors" #pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif #endif
@ -277,6 +278,6 @@ TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") {
REQUIRE(i != j); REQUIRE(i != j);
} }
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -8,6 +8,7 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp> #include <catch2/catch_template_test_macros.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/matchers/catch_matchers_exception.hpp> #include <catch2/matchers/catch_matchers_exception.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp> #include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers_predicate.hpp> #include <catch2/matchers/catch_matchers_predicate.hpp>
@ -21,7 +22,7 @@
#include <list> #include <list>
#include <sstream> #include <sstream>
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wpadded"
@ -1083,7 +1084,7 @@ TEST_CASE( "Matchers can take references",
REQUIRE_THAT( 22, ReferencingMatcher{} ); REQUIRE_THAT( 22, ReferencingMatcher{} );
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -7,6 +7,7 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/matchers/catch_matchers_container_properties.hpp> #include <catch2/matchers/catch_matchers_container_properties.hpp>
#include <catch2/matchers/catch_matchers_contains.hpp> #include <catch2/matchers/catch_matchers_contains.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp> #include <catch2/matchers/catch_matchers_floating_point.hpp>
@ -46,7 +47,7 @@ namespace unrelated {
}; };
} // end unrelated namespace } // end unrelated namespace
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic push # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-function" # pragma clang diagnostic ignored "-Wunused-function"
#endif #endif
@ -107,7 +108,7 @@ public:
} }
}; };
#if defined(__clang__) #if defined(CATCH_COMPILER_CLANG)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -7,6 +7,7 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <iostream> #include <iostream>
TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) { 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(); SUCCEED();
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value" // In (1, 2), the "1" is unused ... #pragma clang diagnostic ignored "-Wunused-value" // In (1, 2), the "1" is unused ...
#endif #endif
@ -247,7 +248,7 @@ std::ostream& operator<<(std::ostream& out, helper_1436<T1, T2> const& helper) {
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wcomma-subscript" #pragma GCC diagnostic ignored "-Wcomma-subscript"
#elif defined(__clang__) #elif defined(CATCH_COMPILER_CLANG)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunknown-warning-option" #pragma clang diagnostic ignored "-Wunknown-warning-option"
@ -276,7 +277,7 @@ TEST_CASE("CAPTURE parses string and character constants", "[messages][capture]"
SUCCEED(); SUCCEED();
} }
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
#ifdef CATCH_COMPILER_GCC #ifdef CATCH_COMPILER_GCC

View File

@ -8,10 +8,11 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp> #include <catch2/catch_template_test_macros.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_config_wchar.hpp> #include <catch2/internal/catch_config_wchar.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp> #include <catch2/internal/catch_windows_h_proxy.hpp>
#ifdef __clang__ #ifdef CATCH_COMPILER_CLANG
# pragma clang diagnostic ignored "-Wc++98-compat" # pragma clang diagnostic ignored "-Wc++98-compat"
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" # pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif #endif

View File

@ -6,7 +6,9 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#ifdef __clang__ #include <catch2/internal/catch_compiler_capabilities.hpp>
#ifdef CATCH_COMPILER_CLANG
#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wpadded"
#endif #endif