1 // (C) Copyright John Maddock 2014-9.
2 // (C) Copyright Andrey Semashev 2017.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/config.hpp>
9 int test_fallthrough(int n
)
23 int test_unreachable(int i
)
25 if(BOOST_LIKELY(i
)) return i
;
28 BOOST_UNREACHABLE_RETURN(0) // NOTE: no semicolon afterwards!!
31 BOOST_FORCEINLINE
int always_inline(int i
){ return ++i
; }
32 BOOST_NOINLINE
int never_inline(int i
){ return ++i
; }
34 BOOST_NORETURN
void always_throw()
39 struct BOOST_MAY_ALIAS aliasing_struct
{};
40 typedef unsigned int BOOST_MAY_ALIAS aliasing_uint
;
42 struct BOOST_ATTRIBUTE_NODISCARD nodiscard_struct
{};
45 #define test_fallthrough(x) foobar(x)
51 BOOST_ATTRIBUTE_NO_UNIQUE_ADDRESS empty b
;
57 typedef int unused_type BOOST_ATTRIBUTE_UNUSED
;
60 int result
= test_fallthrough
BOOST_PREVENT_MACRO_SUBSTITUTION(0);
61 BOOST_STATIC_CONSTANT(bool, value
= 0);
62 result
+= test_unreachable(1);
63 result
+= always_inline(2);
64 result
+= never_inline(3);
65 if(BOOST_UNLIKELY(!result
))