[libsigc++2] Fix 'make check' with clang++ and --enable-warnings=fatal



commit 1ce41a0a59214d896d2dead06f5431440a8b6c34
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon Jul 14 15:54:37 2014 +0200

    Fix 'make check' with clang++ and --enable-warnings=fatal
    
    * tests/test_cpp11_lambda.cc:
    * tests/test_deduce_result_type.cc:
    * tests/test_track_obj.cc: Don't define functions which are not used.
    The clang++ compiler considers unused functions an error, when libsigc++ is
    configured with --enable-warnings=fatal. Bug #724496.

 tests/test_cpp11_lambda.cc       |   10 ++++++----
 tests/test_deduce_result_type.cc |   13 ++++++++++++-
 tests/test_track_obj.cc          |   27 +++++++++++++++------------
 3 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index f3d6f09..068e1f5 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -63,7 +63,6 @@ namespace sigc
 {
   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
 }
-#endif
 
 namespace
 {
@@ -146,6 +145,8 @@ void foo_group4(bar_group4&)
 
 } // end anonymous namespace
 
+#endif // USING_CPP11_LAMBDA_EXPRESSIONS
+
 
 int main(int argc, char* argv[])
 {
@@ -504,10 +505,11 @@ int main(int argc, char* argv[])
     some_signal.emit();
     util->check_result(result_stream, "");
   }
+  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
 #else // not USING_CPP11_LAMBDA_EXPRESSIONS
   std::cout << "The compiler capabilities don't allow test of C++11 lambda expressions." << std::endl;
+  // Return code 77 tells automake's test harness to skip this test.
+  return util->get_result_and_delete_instance() ? 77 : EXIT_FAILURE;
 #endif
-
-  return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+} // end main()
diff --git a/tests/test_deduce_result_type.cc b/tests/test_deduce_result_type.cc
index d8ddf93..db73eb4 100644
--- a/tests/test_deduce_result_type.cc
+++ b/tests/test_deduce_result_type.cc
@@ -38,9 +38,17 @@ struct foo : public sigc::functor_base
   double operator()(const int&, int);
 };
 
-struct foo2 :public foo
+struct foo2 : public foo
 {};
 
+struct foo3 : public sigc::functor_base
+{
+  typedef int result_type;
+
+  int operator()(int i = 1);
+  double operator()(const int&, int);
+};
+
 } // end anonymous namespace
 
 int main(int argc, char* argv[])
@@ -56,6 +64,9 @@ int main(int argc, char* argv[])
   bar(sigc::deduce_result_type<foo2, int, int>::type());
   util->check_result(result_stream, "double");
 
+  bar(sigc::deduce_result_type<foo3, int, int>::type());
+  util->check_result(result_stream, "int");
+
 #ifdef FAIL
   bar(sigc::deduce_result_type<foo2, int, int, int>::type());
   util->check_result(result_stream, "double");
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index 5e8a824..80fcd59 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -56,12 +56,6 @@ namespace
 {
 std::ostringstream result_stream;
 
-void egon(std::string& str)
-{
-  result_stream << "egon(string '" << str << "')";
-  str = "egon was here";
-}
-
 struct book : public sigc::trackable
 {
   explicit book(const std::string& name) : name_(name) {}
@@ -70,12 +64,6 @@ struct book : public sigc::trackable
   std::string name_;
 };
 
-inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
-{
-  s << b.name_;
-  return s;
-}
-
 struct bar_group4 : public sigc::trackable
 {
 };
@@ -118,10 +106,25 @@ private:
   const book& aBook_;
 };
 
+#ifdef USING_CPP11_LAMBDA_EXPRESSIONS
+
+inline std::ostringstream& operator << (std::ostringstream& s, const book& b)
+{
+  s << b.name_;
+  return s;
+}
+
+void egon(std::string& str)
+{
+  result_stream << "egon(string '" << str << "')";
+  str = "egon was here";
+}
+
 void foo_group4(bar_group4&)
 {
   result_stream << "foo_group4(bar_group4&)";
 }
+#endif // USING_CPP11_LAMBDA_EXPRESSIONS
 
 } // end anonymous namespace
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]