$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83958 - in trunk: boost/config boost/config/compiler libs/config/doc libs/config/doc/html libs/config/doc/html/boost_config libs/config/test
From: john_at_[hidden]
Date: 2013-04-18 13:50:19
Author: johnmaddock
Date: 2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
New Revision: 83958
URL: http://svn.boost.org/trac/boost/changeset/83958
Log:
Apply patch from #8408.
Fixes #8408.
Added:
   trunk/libs/config/test/boost_fallthrough_test.cpp   (contents, props changed)
Text files modified: 
   trunk/boost/config/compiler/clang.hpp                              |    10 ++++++++                                
   trunk/boost/config/suffix.hpp                                      |    10 ++++++++                                
   trunk/libs/config/doc/html/boost_config/boost_macro_reference.html |    48 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/config/doc/html/index.html                              |     2                                         
   trunk/libs/config/doc/macro_reference.qbk                          |    35 +++++++++++++++++++++++++++++           
   trunk/libs/config/test/Jamfile.v2                                  |     1                                         
   trunk/libs/config/test/config_info.cpp                             |    22 -----------------                       
   7 files changed, 106 insertions(+), 22 deletions(-)
Modified: trunk/boost/config/compiler/clang.hpp
==============================================================================
--- trunk/boost/config/compiler/clang.hpp	(original)
+++ trunk/boost/config/compiler/clang.hpp	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -38,6 +38,16 @@
 #  define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
 #endif
 
+// 
+// The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 
+// between switch labels. 
+// 
+#if __cplusplus >= 201103L && defined(__has_warning) 
+#  if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") 
+#    define BOOST_FALLTHROUGH [[clang::fallthrough]] 
+#  endif 
+#endif 
+
 #if !__has_feature(cxx_auto_type)
 #  define BOOST_NO_CXX11_AUTO_DECLARATIONS
 #  define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
Modified: trunk/boost/config/suffix.hpp
==============================================================================
--- trunk/boost/config/suffix.hpp	(original)
+++ trunk/boost/config/suffix.hpp	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -883,6 +883,16 @@
 #  define BOOST_NOEXCEPT_IF(Predicate) noexcept((Predicate))
 #  define BOOST_NOEXCEPT_EXPR(Expression) noexcept((Expression))
 #endif
+//
+// Helper macro BOOST_FALLTHROUGH 
+// Fallback definition of BOOST_FALLTHROUGH macro used to mark intended 
+// fall-through between case labels in a switch statement. We use a definition 
+// that requires a semicolon after it to avoid at least one type of misuse even 
+// on unsupported compilers. 
+// 
+#ifndef BOOST_FALLTHROUGH 
+#  define BOOST_FALLTHROUGH ((void)0) 
+#endif 
 
 //
 // constexpr workarounds
Modified: trunk/libs/config/doc/html/boost_config/boost_macro_reference.html
==============================================================================
--- trunk/libs/config/doc/html/boost_config/boost_macro_reference.html	(original)
+++ trunk/libs/config/doc/html/boost_config/boost_macro_reference.html	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -3384,6 +3384,54 @@
 <tr>
 <td>
                 <p>
+                  <code class="computeroutput"><span class="identifier">BOOST_FALLTHROUGH</span></code>
+                </p>
+              </td>
+<td>
+                <p>
+                  The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
+                  between switch labels:
+</p>
+<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>
+<span class="keyword">case</span> <span class="number">40</span><span class="special">:</span>
+<span class="keyword">case</span> <span class="number">41</span><span class="special">:</span>
+   <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>
+      <span class="special">++</span><span class="identifier">x</span><span class="special">;</span>
+      <span class="identifier">BOOST_FALLTHROUGH</span><span class="special">;</span>  <span class="comment">// Use instead of/along with annotations in </span>
+      <span class="comment">// comments. </span>
+   <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span>
+     <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span>
+   <span class="special">}</span>
+   <span class="keyword">case</span> <span class="number">42</span><span class="special">:</span>
+      <span class="special">...</span>
+</pre>
+<p>
+                  As shown in the example above, the BOOST_FALLTHROUGH macro should
+                  be followed by a semicolon. It is designed to mimic control-flow
+                  statements like 'break;', so it can be placed in most places where
+                  'break;' can, but only if there are no statements on the execution
+                  path between it and the next switch label.
+                </p>
+                <p>
+                  When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH
+                  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>
+                  attribute, which is analysed when performing switch labels fall-through
+                  diagnostic ('-Wimplicit-fallthrough'). See clang <a href="http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough" target="_top">documentation
+                  on language extensions for details.</a>
+                </p>
+                <p>
+                  When used with unsupported compilers, the BOOST_FALLTHROUGH macro
+                  has no effect on diagnostics.
+                </p>
+                <p>
+                  In either case this macro has no effect on runtime behavior and
+                  performance of code.
+                </p>
+              </td>
+</tr>
+<tr>
+<td>
+                <p>
                   <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>
                 </p>
               </td>
Modified: trunk/libs/config/doc/html/index.html
==============================================================================
--- trunk/libs/config/doc/html/index.html	(original)
+++ trunk/libs/config/doc/html/index.html	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -951,7 +951,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: February 19, 2013 at 16:25:18 GMT</small></p></td>
+<td align="left"><p><small>Last revised: April 18, 2013 at 17:44:14 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>
Modified: trunk/libs/config/doc/macro_reference.qbk
==============================================================================
--- trunk/libs/config/doc/macro_reference.qbk	(original)
+++ trunk/libs/config/doc/macro_reference.qbk	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -862,6 +862,41 @@
 Normally evaluates to nothing, but evaluates to return x; if the compiler
 requires a return, even when it can never be reached.
 ]]
+[[`BOOST_FALLTHROUGH`][ 
+The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through 
+between switch labels: 
+`` 
+ switch (x) { 
+ case 40: 
+ case 41: 
+    if (truth_is_out_there) { 
+       ++x; 
+       BOOST_FALLTHROUGH;  // Use instead of/along with annotations in 
+       // comments. 
+    } else { 
+      return x; 
+    } 
+    case 42: 
+       ... 
+`` 
+As shown in the example above, the BOOST_FALLTHROUGH macro should be 
+followed by a semicolon. It is designed to mimic control-flow statements 
+like 'break;', so it can be placed in most places where 'break;' can, but 
+only if there are no statements on the execution path between it and the 
+next switch label. 
+
+When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH macro is 
+expanded to `[[clang::fallthrough]]` attribute, which is analysed when 
+performing switch labels fall-through diagnostic ('-Wimplicit-fallthrough'). 
+See clang [@http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough 
+documentation on language extensions for details.] 
+
+When used with unsupported compilers, the BOOST_FALLTHROUGH macro has no 
+effect on diagnostics. 
+
+In either case this macro has no effect on runtime behavior and performance 
+of code. 
+]] 
 [[`BOOST_EXPLICIT_TEMPLATE_TYPE(t)`
   `BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)`
   `BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)`
Modified: trunk/libs/config/test/Jamfile.v2
==============================================================================
--- trunk/libs/config/test/Jamfile.v2	(original)
+++ trunk/libs/config/test/Jamfile.v2	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -65,4 +65,5 @@
     ]
     [ compile-fail threads/test_thread_fail1.cpp ]
     [ compile-fail threads/test_thread_fail2.cpp ]
+    [ compile boost_fallthrough_test.cpp : <toolset>clang:<cxxflags>"-std=c++11 -Wimplicit-fallthrough" <warnings-as-errors>on <warnings>all ]
   ;
Added: trunk/libs/config/test/boost_fallthrough_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/config/test/boost_fallthrough_test.cpp	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -0,0 +1,20 @@
+//  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) 
+
+#include <boost/config.hpp> 
+
+int test(int n) 
+{ 
+   switch (n) 
+   { 
+   case 0: 
+      n++; 
+      BOOST_FALLTHROUGH; 
+   case 1: 
+      n++; 
+      break; 
+   } 
+   return n; 
+}
+
Modified: trunk/libs/config/test/config_info.cpp
==============================================================================
--- trunk/libs/config/test/config_info.cpp	(original)
+++ trunk/libs/config/test/config_info.cpp	2013-04-18 13:50:17 EDT (Thu, 18 Apr 2013)
@@ -1100,27 +1100,6 @@
    PRINT_MACRO(BOOST_NO_USING_TEMPLATE);
    PRINT_MACRO(BOOST_NO_VOID_RETURNS);
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
    // END GENERATED BLOCK
 
    PRINT_MACRO(BOOST_INTEL);
@@ -1132,6 +1111,7 @@
    PRINT_MACRO(BOOST_STATIC_CONSTEXPR);
    PRINT_MACRO(BOOST_NOEXCEPT);
    PRINT_MACRO(BOOST_FORCEINLINE);
+   PRINT_MACRO(BOOST_FALLTHROUGH);
 }
 
 void print_separator()