Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Jeřábek2024-02-19 18:17:42 +0100
committerMartin Hořeňovský2024-03-01 21:24:45 +0100
commitda303cc6687326e73f4272855984498046519851 (patch)
tree36a69e2122680a85d23d56805c58a99453db3ef8
parentc3fd4eb17e28ace4d3d9df1fb0656f3975879709 (diff)
downloadcatch3-da303cc6687326e73f4272855984498046519851.tar.gz
Evaluate argument of (DYNAMIC_)SECTION in static-analysis mode
-rw-r--r--src/catch2/internal/catch_section.hpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp
index 8c894eeb..e56c79f3 100644
--- a/src/catch2/internal/catch_section.hpp
+++ b/src/catch2/internal/catch_section.hpp
@@ -69,7 +69,9 @@ namespace Catch {
namespace Detail {
// Intentionally without linkage, as it should only be used as a dummy
// symbol for static analysis.
- int GetNewSectionHint();
+ // The arguments are used as a dummy for checking warnings in the passed
+ // expressions.
+ int GetNewSectionHint( StringRef, const char* const = nullptr );
} // namespace Detail
} // namespace Catch
@@ -80,7 +82,8 @@ namespace Catch {
CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \
catchInternalSectionHint, \
- catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \
+ catchInternalSectionHint = \
+ Catch::Detail::GetNewSectionHint(__VA_ARGS__); \
catchInternalPreviousSectionHint == __LINE__ ) \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
@@ -90,7 +93,8 @@ namespace Catch {
CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \
catchInternalSectionHint, \
- catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \
+ catchInternalSectionHint = Catch::Detail::GetNewSectionHint( \
+ ( Catch::ReusableStringStream() << __VA_ARGS__ ).str()); \
catchInternalPreviousSectionHint == __LINE__ ) \
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION