]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/config/test/helper_macro_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / config / test / helper_macro_test.cpp
CommitLineData
7c673cae
FG
1// Use, modification and distribution are subject to the
2// Boost Software License, Version 1.0. (See accompanying file
3// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5#include <boost/config.hpp>
6
7int test_fallthrough(int n)
8{
9 switch (n)
10 {
11 case 0:
12 n++;
13 BOOST_FALLTHROUGH;
14 case 1:
15 n++;
16 break;
17 }
18 return n;
19}
20
21int test_unreachable(int i)
22{
23 if(BOOST_LIKELY(i)) return i;
24
25 throw i;
26 BOOST_UNREACHABLE_RETURN(0);
27}
28
29BOOST_FORCEINLINE int always_inline(int i){ return ++i; }
30BOOST_NOINLINE int never_inline(int i){ return ++i; }
31
32BOOST_NORETURN void always_throw()
33{
34 throw 0;
35}
36
37
38#define test_fallthrough(x) foobar(x)
39
40
41int main()
42{
43 typedef int unused_type BOOST_ATTRIBUTE_UNUSED;
44 try
45 {
46 int result = test_fallthrough BOOST_PREVENT_MACRO_SUBSTITUTION(0);
47 BOOST_STATIC_CONSTANT(bool, value = 0);
48 result += test_unreachable(1);
49 result += always_inline(2);
50 result += never_inline(3);
51 if(BOOST_UNLIKELY(!result))
52 always_throw();
53 }
54 catch(int)
55 {
56 return 1;
57 }
58 return 0;
59}
60