summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/serialization/test/test_static_warning.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/serialization/test/test_static_warning.cpp
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/serialization/test/test_static_warning.cpp')
-rw-r--r--src/boost/libs/serialization/test/test_static_warning.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/boost/libs/serialization/test/test_static_warning.cpp b/src/boost/libs/serialization/test/test_static_warning.cpp
new file mode 100644
index 000000000..642b9cf3a
--- /dev/null
+++ b/src/boost/libs/serialization/test/test_static_warning.cpp
@@ -0,0 +1,63 @@
+// (C) Copyright Jonathan Turkanis 2004.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for most recent version including documentation.
+
+// note: this is a compile only test.
+
+#include <boost/config.hpp> // BOOST_STATIC_CONST
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
+
+#include <boost/serialization/static_warning.hpp>
+
+typedef char a1[2];
+typedef char a2[3];
+
+class polymorphic {
+ virtual ~polymorphic();
+};
+
+class non_polymorphic {
+};
+
+template<class T>
+int f(){
+ BOOST_STATIC_WARNING(T::value);
+ return 0;
+}
+
+struct A {
+ BOOST_STATIC_CONSTANT(bool, value = false);
+};
+
+/////////////////////////////////////////////////////////////////////////
+// compilation of this program should show a total of 10 warning messages
+
+// should show NO warning message
+BOOST_STATIC_WARNING(true);
+
+// the following should show 5 warning message
+int x = f<A>(); // Warn
+int y = f<boost::is_polymorphic<non_polymorphic> >(); // Warn.
+int z = f<boost::is_polymorphic<polymorphic> >();
+
+BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn.
+BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn.
+BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn.
+BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn.
+
+int main(int /* argc */, char * /* argv */[]){
+ // should show NO warning message
+ BOOST_STATIC_WARNING(true);
+
+ // the following should show 5 warning message
+ f<A>();
+ BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn.
+ BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn.
+ BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn.
+ BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn.
+ return 0;
+}