]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/config/test/helper_macro_test.cpp
update sources to v12.2.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
b32b8144
FG
37struct BOOST_MAY_ALIAS aliasing_struct {};
38typedef unsigned int BOOST_MAY_ALIAS aliasing_uint;
39
7c673cae
FG
40
41#define test_fallthrough(x) foobar(x)
42
43
44int main()
45{
46 typedef int unused_type BOOST_ATTRIBUTE_UNUSED;
47 try
48 {
49 int result = test_fallthrough BOOST_PREVENT_MACRO_SUBSTITUTION(0);
50 BOOST_STATIC_CONSTANT(bool, value = 0);
51 result += test_unreachable(1);
52 result += always_inline(2);
53 result += never_inline(3);
54 if(BOOST_UNLIKELY(!result))
55 always_throw();
56 }
57 catch(int)
58 {
59 return 1;
60 }
61 return 0;
62}
63