|
62 | 62 | # define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
|
63 | 63 | _Pragma( "GCC diagnostic ignored \"-Wshadow\"" )
|
64 | 64 |
|
65 |
| -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) |
| 65 | +# define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P |
66 | 66 |
|
67 | 67 | #endif
|
68 | 68 |
|
|
86 | 86 | // clang-cl defines _MSC_VER as well as __clang__, which could cause the
|
87 | 87 | // start/stop internal suppression macros to be double defined.
|
88 | 88 | #if defined(__clang__) && !defined(_MSC_VER)
|
89 |
| - |
| 89 | +# define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P |
90 | 90 | # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
|
91 | 91 | # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )
|
92 |
| - |
93 | 92 | #endif // __clang__ && !_MSC_VER
|
94 | 93 |
|
95 | 94 | #if defined(__clang__)
|
96 | 95 |
|
97 |
| -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug |
98 |
| -// which results in calls to destructors being emitted for each temporary, |
99 |
| -// without a matching initialization. In practice, this can result in something |
100 |
| -// like `std::string::~string` being called on an uninitialized value. |
101 |
| -// |
102 |
| -// For example, this code will likely segfault under IBM XL: |
103 |
| -// ``` |
104 |
| -// REQUIRE(std::string("12") + "34" == "1234") |
105 |
| -// ``` |
106 |
| -// |
107 |
| -// Similarly, NVHPC's implementation of `__builtin_constant_p` has a bug which |
108 |
| -// results in calls to the immediately evaluated lambda expressions to be |
109 |
| -// reported as unevaluated lambdas. |
110 |
| -// https://developer.nvidia.com/nvidia_bug/3321845. |
111 |
| -// |
112 |
| -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. |
113 |
| -# if !defined(__ibmxl__) && !defined(__CUDACC__) && !defined( __NVCOMPILER ) |
114 |
| -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ |
115 |
| -# endif |
116 |
| - |
117 |
| - |
118 | 96 | # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
|
119 | 97 | _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
|
120 | 98 | _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
|
|
139 | 117 |
|
140 | 118 | #endif // __clang__
|
141 | 119 |
|
| 120 | +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug |
| 121 | +// which results in calls to destructors being emitted for each temporary, |
| 122 | +// without a matching initialization. In practice, this can result in something |
| 123 | +// like `std::string::~string` being called on an uninitialized value. |
| 124 | +// |
| 125 | +// For example, this code will likely segfault under IBM XL: |
| 126 | +// ``` |
| 127 | +// REQUIRE(std::string("12") + "34" == "1234") |
| 128 | +// ``` |
| 129 | +// |
| 130 | +// Similarly, NVHPC's implementation of `__builtin_constant_p` has a bug which |
| 131 | +// results in calls to the immediately evaluated lambda expressions to be |
| 132 | +// reported as unevaluated lambdas. |
| 133 | +// https://developer.nvidia.com/nvidia_bug/3321845. |
| 134 | +// |
| 135 | +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. |
| 136 | +#if defined( __ibmxl__ ) || defined( __CUDACC__ ) || defined( __NVCOMPILER ) |
| 137 | +# define CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P |
| 138 | +#endif |
| 139 | + |
| 140 | + |
142 | 141 |
|
143 | 142 | ////////////////////////////////////////////////////////////////////////////////
|
144 | 143 | // We know some environments not to support full POSIX signals
|
|
362 | 361 | #endif
|
363 | 362 |
|
364 | 363 |
|
| 364 | +// The goal of this macro is to avoid evaluation of the arguments, but |
| 365 | +// still have the compiler warn on problems inside... |
| 366 | +#if defined( CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P ) && \ |
| 367 | + !defined( CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P ) && !defined(CATCH_CONFIG_USE_BUILTIN_CONSTANT_P) |
| 368 | +#define CATCH_CONFIG_USE_BUILTIN_CONSTANT_P |
| 369 | +#endif |
| 370 | + |
| 371 | +#if defined( CATCH_CONFIG_USE_BUILTIN_CONSTANT_P ) && \ |
| 372 | + !defined( CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P ) |
| 373 | +# define CATCH_INTERNAL_IGNORE_BUT_WARN( ... ) \ |
| 374 | + (void)__builtin_constant_p( __VA_ARGS__ ) /* NOLINT(cppcoreguidelines-pro-type-vararg, \ |
| 375 | + hicpp-vararg) */ |
| 376 | +#else |
| 377 | +# define CATCH_INTERNAL_IGNORE_BUT_WARN( ... ) |
| 378 | +#endif |
| 379 | + |
365 | 380 | // Even if we do not think the compiler has that warning, we still have
|
366 | 381 | // to provide a macro that can be used by the code.
|
367 | 382 | #if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION)
|
|
398 | 413 | # define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS
|
399 | 414 | #endif
|
400 | 415 |
|
401 |
| - |
402 |
| -// The goal of this macro is to avoid evaluation of the arguments, but |
403 |
| -// still have the compiler warn on problems inside... |
404 |
| -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) |
405 |
| -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) |
406 |
| -#endif |
407 |
| - |
408 | 416 | #if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10)
|
409 | 417 | # undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
|
410 | 418 | #elif defined(__clang__) && (__clang_major__ < 5)
|
|
0 commit comments