[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 08fded5 1/3: Test stifle_unused_warning() wit
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 08fded5 1/3: Test stifle_unused_warning() with temporaries |
Date: |
Thu, 28 Oct 2021 12:15:47 -0400 (EDT) |
branch: master
commit 08fded5f02051704fc0c48e4cfaa9a685ad18389
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Test stifle_unused_warning() with temporaries
Before deciding whether this use case is important enough, it is useful
to have a unit test that ascertains whether or not it works.
---
miscellany_test.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index 0de17a6..1f63ac6 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -470,6 +470,9 @@ class partly_unused
int unused_;
};
+int return_temporary_0() {return {};}
+std::string return_temporary_1() {return {};}
+
void test_stifle_unused_warning()
{
// Variable neither initialized nor used.
@@ -503,6 +506,9 @@ void test_stifle_unused_warning()
// https://lists.nongnu.org/archive/html/lmi/2021-04/msg00058.html
partly_unused {0, 1};
+
+ stifle_unused_warning(return_temporary_0());
+ stifle_unused_warning(return_temporary_1());
}
int test_main(int, char*[])