Ticket #8408: boost-config-fallthrough.patch
File boost-config-fallthrough.patch, 18.9 KB (added by , 10 years ago) |
---|
-
boost/config/compiler/clang.hpp
38 38 # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) 39 39 #endif 40 40 41 // 42 // The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 43 // between switch labels. 44 // 45 #if __cplusplus >= 201103L && defined(__has_warning) 46 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") 47 # define BOOST_FALLTHROUGH [[clang::fallthrough]] 48 # endif 49 #endif 50 41 51 #if !__has_feature(cxx_auto_type) 42 52 # define BOOST_NO_CXX11_AUTO_DECLARATIONS 43 53 # define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS -
boost/config/suffix.hpp
885 885 #endif 886 886 887 887 // 888 // Helper macro BOOST_FALLTHROUGH 889 // Fallback definition of BOOST_FALLTHROUGH macro used to mark intended 890 // fall-through between case labels in a switch statement. We use a definition 891 // that requires a semicolon after it to avoid at least one type of misuse even 892 // on unsupported compilers. 893 // 894 #ifndef BOOST_FALLTHROUGH 895 # define BOOST_FALLTHROUGH ((void)0) 896 #endif 897 898 // 888 899 // constexpr workarounds 889 900 // 890 901 #if defined(BOOST_NO_CXX11_CONSTEXPR) -
libs/config/doc/html/boost_config/acknowledgements.html
3 3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 4 4 <title>Acknowledgements</title> 5 5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.7 7.1">6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> 7 7 <link rel="home" href="../index.html" title="Boost.Config"> 8 8 <link rel="up" href="../index.html" title="Boost.Config"> 9 9 <link rel="prev" href="rationale.html" title="Rationale"> -
libs/config/doc/html/boost_config/boost_macro_reference.html
3 3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 4 4 <title>Boost Macro Reference</title> 5 5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.7 7.1">6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> 7 7 <link rel="home" href="../index.html" title="Boost.Config"> 8 8 <link rel="up" href="../index.html" title="Boost.Config"> 9 9 <link rel="prev" href="../index.html" title="Boost.Config"> … … 26 26 <div class="titlepage"><div><div><h2 class="title" style="clear: both"> 27 27 <a name="boost_config.boost_macro_reference"></a><a class="link" href="boost_macro_reference.html" title="Boost Macro Reference">Boost Macro Reference</a> 28 28 </h2></div></div></div> 29 <div class="toc"><dl >29 <div class="toc"><dl class="toc"> 30 30 <dt><span class="section"><a href="boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__03_defects">Macros 31 31 that describe C++03 defects</a></span></dt> 32 32 <dt><span class="section"><a href="boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_optional_features">Macros … … 3384 3384 <tr> 3385 3385 <td> 3386 3386 <p> 3387 <code class="computeroutput"><span class="identifier">BOOST_FALLTHROUGH</span></code> 3388 </p> 3389 </td> 3390 <td> 3391 <p> 3392 The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 3393 between switch labels: 3394 </p> 3395 <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">switch</span> <span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> 3396 <span class="keyword">case</span> <span class="number">40</span><span class="special">:</span> 3397 <span class="keyword">case</span> <span class="number">41</span><span class="special">:</span> 3398 <span class="keyword">if</span> <span class="special">(</span><span class="identifier">truth_is_out_there</span><span class="special">)</span> <span class="special">{</span> 3399 <span class="special">++</span><span class="identifier">x</span><span class="special">;</span> 3400 <span class="identifier">BOOST_FALLTHROUGH</span><span class="special">;</span> <span class="comment">// Use instead of/along with annotations in</span> 3401 <span class="comment">// comments.</span> 3402 <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> 3403 <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> 3404 <span class="special">}</span> 3405 <span class="keyword">case</span> <span class="number">42</span><span class="special">:</span> 3406 <span class="special">...</span> 3407 </pre> 3408 <p> 3409 As shown in the example above, the BOOST_FALLTHROUGH macro should 3410 be followed by a semicolon. It is designed to mimic control-flow 3411 statements like 'break;', so it can be placed in most places where 3412 'break;' can, but only if there are no statements on the execution 3413 path between it and the next switch label. 3414 </p> 3415 <p> 3416 When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH 3417 macro is expanded to <code class="computeroutput"><span class="special">[[</span><span class="identifier">clang</span><span class="special">::</span><span class="identifier">fallthrough</span><span class="special">]]</span></code> 3418 attribute, which is analysed when performing switch labels fall-through 3419 diagnostic ('-Wimplicit-fallthrough'). See clang documentation 3420 on language extensions for details: http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough 3421 </p> 3422 <p> 3423 When used with unsupported compilers, the BOOST_FALLTHROUGH macro 3424 has no effect on diagnostics. 3425 </p> 3426 <p> 3427 In either case this macro has no effect on runtime behavior and 3428 performance of code. 3429 </p> 3430 </td> 3431 </tr> 3432 <tr> 3433 <td> 3434 <p> 3387 3435 <code class="computeroutput"><span class="identifier">BOOST_EXPLICIT_TEMPLATE_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_EXPLICIT_TEMPLATE_NON_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code> 3388 3436 </p> 3389 3437 </td> … … 4923 4971 <a name="boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code"></a><a class="link" href="boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code" title="Macros for libraries with separate source code">Macros 4924 4972 for libraries with separate source code</a> 4925 4973 </h3></div></div></div> 4926 <div class="toc"><dl >4974 <div class="toc"><dl class="toc"> 4927 4975 <dt><span class="section"><a href="boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code.macros_controlling_shared_library_symbol_visibility">Macros 4928 4976 controlling shared library symbol visibility</a></span></dt> 4929 4977 <dt><span class="section"><a href="boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code.abi_fixing">ABI -
libs/config/doc/html/boost_config/guidelines_for_boost_authors.html
3 3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 4 4 <title>Guidelines for Boost Authors</title> 5 5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.7 7.1">6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> 7 7 <link rel="home" href="../index.html" title="Boost.Config"> 8 8 <link rel="up" href="../index.html" title="Boost.Config"> 9 9 <link rel="prev" href="boost_macro_reference.html" title="Boost Macro Reference"> … … 27 27 <a name="boost_config.guidelines_for_boost_authors"></a><a class="link" href="guidelines_for_boost_authors.html" title="Guidelines for Boost Authors">Guidelines for 28 28 Boost Authors</a> 29 29 </h2></div></div></div> 30 <div class="toc"><dl >30 <div class="toc"><dl class="toc"> 31 31 <dt><span class="section"><a href="guidelines_for_boost_authors.html#boost_config.guidelines_for_boost_authors.warnings">Disabling 32 32 Compiler Warnings</a></span></dt> 33 33 <dt><span class="section"><a href="guidelines_for_boost_authors.html#boost_config.guidelines_for_boost_authors.adding_new_defect_macros">Adding -
libs/config/doc/html/boost_config/rationale.html
3 3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 4 4 <title>Rationale</title> 5 5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.7 7.1">6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> 7 7 <link rel="home" href="../index.html" title="Boost.Config"> 8 8 <link rel="up" href="../index.html" title="Boost.Config"> 9 9 <link rel="prev" href="guidelines_for_boost_authors.html" title="Guidelines for Boost Authors"> … … 26 26 <div class="titlepage"><div><div><h2 class="title" style="clear: both"> 27 27 <a name="boost_config.rationale"></a><a class="link" href="rationale.html" title="Rationale">Rationale</a> 28 28 </h2></div></div></div> 29 <div class="toc"><dl >29 <div class="toc"><dl class="toc"> 30 30 <dt><span class="section"><a href="rationale.html#boost_config.rationale.the_problem">The problem</a></span></dt> 31 31 <dt><span class="section"><a href="rationale.html#boost_config.rationale.the_solution">The solution</a></span></dt> 32 32 </dl></div> -
libs/config/doc/html/index.html
3 3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 4 4 <title>Boost.Config</title> 5 5 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6 <meta name="generator" content="DocBook XSL Stylesheets V1.7 7.1">6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> 7 7 <link rel="home" href="index.html" title="Boost.Config"> 8 8 <link rel="next" href="boost_config/boost_macro_reference.html" title="Boost Macro Reference"> 9 9 </head> … … 39 39 </div> 40 40 <div class="toc"> 41 41 <p><b>Table of Contents</b></p> 42 <dl >42 <dl class="toc"> 43 43 <dt><span class="section"><a href="index.html#boost_config.configuring_boost_for_your_platform">Configuring 44 44 Boost for Your Platform</a></span></dt> 45 45 <dd><dl> … … 102 102 <a name="boost_config.configuring_boost_for_your_platform"></a><a class="link" href="index.html#boost_config.configuring_boost_for_your_platform" title="Configuring Boost for Your Platform">Configuring 103 103 Boost for Your Platform</a> 104 104 </h2></div></div></div> 105 <div class="toc"><dl >105 <div class="toc"><dl class="toc"> 106 106 <dt><span class="section"><a href="index.html#boost_config.configuring_boost_for_your_platform.using_the_default_boost_configuration">Using 107 107 the default boost configuration</a></span></dt> 108 108 <dt><span class="section"><a href="index.html#boost_config.configuring_boost_for_your_platform.the__boost_config_hpp__header">The … … 684 684 <a name="boost_config.configuring_boost_for_your_platform.advanced_configuration_usage"></a><a class="link" href="index.html#boost_config.configuring_boost_for_your_platform.advanced_configuration_usage" title="Advanced configuration usage">Advanced 685 685 configuration usage</a> 686 686 </h3></div></div></div> 687 <div class="toc"><dl >687 <div class="toc"><dl class="toc"> 688 688 <dt><span class="section"><a href="index.html#boost_config.configuring_boost_for_your_platform.advanced_configuration_usage.example_1__creating_our_own_frozen_configuration">Example 689 689 1: creating our own frozen configuration</a></span></dt> 690 690 <dt><span class="section"><a href="index.html#boost_config.configuring_boost_for_your_platform.advanced_configuration_usage.example_2__skipping_files_that_you_don_t_need">Example … … 951 951 </div> 952 952 </div> 953 953 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 954 <td align="left"><p><small>Last revised: February 19, 2013 at 16:25:18GMT</small></p></td>954 <td align="left"><p><small>Last revised: April 05, 2013 at 23:29:41 GMT</small></p></td> 955 955 <td align="right"><div class="copyright-footer"></div></td> 956 956 </tr></table> 957 957 <hr> -
libs/config/doc/macro_reference.qbk
862 862 Normally evaluates to nothing, but evaluates to return x; if the compiler 863 863 requires a return, even when it can never be reached. 864 864 ]] 865 [[`BOOST_FALLTHROUGH`][ 866 The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 867 between switch labels: 868 `` 869 switch (x) { 870 case 40: 871 case 41: 872 if (truth_is_out_there) { 873 ++x; 874 BOOST_FALLTHROUGH; // Use instead of/along with annotations in 875 // comments. 876 } else { 877 return x; 878 } 879 case 42: 880 ... 881 `` 882 As shown in the example above, the BOOST_FALLTHROUGH macro should be 883 followed by a semicolon. It is designed to mimic control-flow statements 884 like 'break;', so it can be placed in most places where 'break;' can, but 885 only if there are no statements on the execution path between it and the 886 next switch label. 887 888 When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH macro is 889 expanded to `[[clang::fallthrough]]` attribute, which is analysed when 890 performing switch labels fall-through diagnostic ('-Wimplicit-fallthrough'). 891 See clang documentation on language extensions for details: 892 http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough 893 894 When used with unsupported compilers, the BOOST_FALLTHROUGH macro has no 895 effect on diagnostics. 896 897 In either case this macro has no effect on runtime behavior and performance 898 of code. 899 ]] 865 900 [[`BOOST_EXPLICIT_TEMPLATE_TYPE(t)` 866 901 `BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)` 867 902 `BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)` -
libs/config/test/Jamfile.v2
65 65 ] 66 66 [ compile-fail threads/test_thread_fail1.cpp ] 67 67 [ compile-fail threads/test_thread_fail2.cpp ] 68 [ compile-fail boost_fallthrough_fail.cpp ] 69 [ compile boost_fallthrough_test.cpp : <toolset>clang:<cxxflags>"-std=c++11 -Werror -Wimplicit-fallthrough" ] 68 70 ; -
libs/config/test/boost_fallthrough_fail.cpp
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 7 int test(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 } -
libs/config/test/boost_fallthrough_test.cpp
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 7 int test(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 } -
libs/config/test/boost_no_std_wstreambuf.ipp
61 61 case ::std::ios_base::beg: 62 62 if((off < 0) || (off > size)) 63 63 return pos_type(off_type(-1)); 64 else65 this->setg(g, g + off, g + size);64 this->setg(g, g + off, g + size); 65 BOOST_FALLTHROUGH; 66 66 case ::std::ios_base::end: 67 67 if((off < 0) || (off > size)) 68 68 return pos_type(off_type(-1)); 69 else70 this->setg(g, g + size - off, g + size);69 this->setg(g, g + size - off, g + size); 70 BOOST_FALLTHROUGH; 71 71 case ::std::ios_base::cur: 72 72 { 73 73 int newpos = pos + off; -
libs/config/test/config_info.cpp
1125 1125 PRINT_MACRO(BOOST_MSVC); 1126 1126 PRINT_MACRO(BOOST_STD_EXTENSION_NAMESPACE); 1127 1127 PRINT_MACRO(BOOST_UNREACHABLE_RETURN(0)); 1128 PRINT_MACRO(BOOST_FALLTHROUGH); 1128 1129 PRINT_MACRO(BOOST_CONSTEXPR); 1129 1130 PRINT_MACRO(BOOST_CONSTEXPR_OR_CONST); 1130 1131 PRINT_MACRO(BOOST_STATIC_CONSTEXPR);