Added BOOST_UNREACHABLE_RETURN workaround macro.

[SVN r16574]
This commit is contained in:
John Maddock
2002-12-09 12:21:54 +00:00
parent 555d41525d
commit 3596eec09a
7 changed files with 111 additions and 5 deletions

View File

@@ -802,6 +802,14 @@ f(&amp;bar); // should choose #2.</pre>
<td>The compiler does not support template template <td>The compiler does not support template template
parameters.</td> parameters.</td>
</tr> </tr>
<tr>
<td>BOOST_NO_UNREACHABLE_RETURN_DETECTION</td>
<td>Compiler</td>
<td>If a return is unreachable, then no return statement
should be required, however some compilers insist on it,
while other issue a bunch of warnings if it is in fact
present.</td>
</tr>
<tr> <tr>
<td valign="top" width="51%">BOOST_NO_USING_TEMPLATE</td> <td valign="top" width="51%">BOOST_NO_USING_TEMPLATE</td>
<td valign="top" width="16%">Compiler</td> <td valign="top" width="16%">Compiler</td>
@@ -904,9 +912,9 @@ present.</p>
<td>BOOST_HAS_NRVO</td> <td>BOOST_HAS_NRVO</td>
<td>Compiler</td> <td>Compiler</td>
<td>Indicated that the compiler supports the named return <td>Indicated that the compiler supports the named return
value optimization (NRVO). Used to select the most efficient value optimization (NRVO). Used to select the most
implementation for some function. See efficient implementation for some function. See <a
<a href="../../boost/operators.hpp">boost/operators.hpp</a> href="../../boost/operators.hpp">boost/operators.hpp</a>
for example.</td> for example.</td>
</tr> </tr>
<tr> <tr>
@@ -1071,6 +1079,12 @@ provide workarounds for compiler/standard library defects.</p>
};</pre> };</pre>
</td> </td>
</tr> </tr>
<tr>
<td>BOOST_UNREACHABLE_RETURN(result)</td>
<td>Normally evaluates to nothing, but evaluates to <font
face="Courier New">return x;</font> if the compiler
requires a return, even when it can never be reached.</td>
</tr>
<tr> <tr>
<td valign="top" width="50%">BOOST_USE_FACET(Type, loc)</td> <td valign="top" width="50%">BOOST_USE_FACET(Type, loc)</td>
<td valign="top" width="50%">When the standard library <td valign="top" width="50%">When the standard library

View File

@@ -309,6 +309,17 @@ namespace std {
# define BOOST_NESTED_TEMPLATE # define BOOST_NESTED_TEMPLATE
#endif #endif
// BOOST_UNREACHABLE_RETURN(x) workaround -------------------------------------//
// Normally evaluates to nothing, unless BOOST_NO_UNREACHABLE_RETURN_DETECTION
// is defined, in which case it evaluates to return x; Use when you have a return
// statement that can never be reached.
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
# define BOOST_UNREACHABLE_RETURN(x) return x;
#else
# define BOOST_UNREACHABLE_RETURN(x)
#endif
// BOOST_DEDUCED_TYPENAME workaround ------------------------------------------// // BOOST_DEDUCED_TYPENAME workaround ------------------------------------------//
// //
// Some compilers don't support the use of `typename' for dependent // Some compilers don't support the use of `typename' for dependent

View File

@@ -1,6 +1,6 @@
# #
# Regression test Jamfile for boost configuration setup. # Regression test Jamfile for boost configuration setup.
# This file was automatically generated on Tue Nov 12 11:07:30 2002, # This file was automatically generated on Mon Dec 9 12:06:12 2002,
# do not edit by hand... # do not edit by hand...
# #
subproject libs/config/test ; subproject libs/config/test ;
@@ -102,6 +102,9 @@ test-suite "BOOST_NO_PRIVATE_IN_AGGREGATE" :
test-suite "BOOST_NO_POINTER_TO_MEMBER_CONST" : test-suite "BOOST_NO_POINTER_TO_MEMBER_CONST" :
[ run no_ptr_mem_const_pass.cpp <lib>../../test/build/prg_exec_monitor ] [ run no_ptr_mem_const_pass.cpp <lib>../../test/build/prg_exec_monitor ]
[ link-fail no_ptr_mem_const_fail.cpp <lib>../../test/build/prg_exec_monitor ] ; [ link-fail no_ptr_mem_const_fail.cpp <lib>../../test/build/prg_exec_monitor ] ;
test-suite "BOOST_NO_UNREACHABLE_RETURN_DETECTION" :
[ run no_ret_det_pass.cpp <lib>../../test/build/prg_exec_monitor ]
[ link-fail no_ret_det_fail.cpp <lib>../../test/build/prg_exec_monitor ] ;
test-suite "BOOST_NO_STRINGSTREAM" : test-suite "BOOST_NO_STRINGSTREAM" :
[ run no_sstream_pass.cpp <lib>../../test/build/prg_exec_monitor ] [ run no_sstream_pass.cpp <lib>../../test/build/prg_exec_monitor ]
[ link-fail no_sstream_fail.cpp <lib>../../test/build/prg_exec_monitor ] ; [ link-fail no_sstream_fail.cpp <lib>../../test/build/prg_exec_monitor ] ;

View File

@@ -915,9 +915,11 @@ void print_boost_macros()
PRINT_MACRO(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION); PRINT_MACRO(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION);
PRINT_MACRO(BOOST_NO_TEMPLATE_TEMPLATES); PRINT_MACRO(BOOST_NO_TEMPLATE_TEMPLATES);
PRINT_MACRO(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS); PRINT_MACRO(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS);
PRINT_MACRO(BOOST_NO_UNREACHABLE_RETURN_DETECTION);
PRINT_MACRO(BOOST_NO_USING_TEMPLATE); PRINT_MACRO(BOOST_NO_USING_TEMPLATE);
PRINT_MACRO(BOOST_NO_VOID_RETURNS); PRINT_MACRO(BOOST_NO_VOID_RETURNS);
PRINT_MACRO(BOOST_STD_EXTENSION_NAMESPACE); PRINT_MACRO(BOOST_STD_EXTENSION_NAMESPACE);
PRINT_MACRO(BOOST_UNREACHABLE_RETURN(0));
} }
void print_separator() void print_separator()

View File

@@ -10,7 +10,7 @@
// Do not edit this file, it was generated automatically by // Do not edit this file, it was generated automatically by
// ../tools/generate from boost_*.cxx on // ../tools/generate from boost_*.cxx on
// Tue Nov 12 11:07:30 2002 // Mon Dec 9 12:06:12 2002
#include <boost/config.hpp> #include <boost/config.hpp>
#define BOOST_INCLUDE_MAIN #define BOOST_INCLUDE_MAIN
@@ -167,6 +167,11 @@ namespace boost_no_private_in_aggregate = empty_boost;
#else #else
namespace boost_no_pointer_to_member_const = empty_boost; namespace boost_no_pointer_to_member_const = empty_boost;
#endif #endif
#ifndef BOOST_NO_UNREACHABLE_RETURN_DETECTION
#include "boost_no_ret_det.cxx"
#else
namespace boost_no_unreachable_return_detection = empty_boost;
#endif
#ifndef BOOST_NO_STRINGSTREAM #ifndef BOOST_NO_STRINGSTREAM
#include "boost_no_sstream.cxx" #include "boost_no_sstream.cxx"
#else #else
@@ -413,6 +418,7 @@ int test_main( int, char *[] )
BOOST_TEST(0 == boost_no_std_distance::test()); BOOST_TEST(0 == boost_no_std_distance::test());
BOOST_TEST(0 == boost_no_std_allocator::test()); BOOST_TEST(0 == boost_no_std_allocator::test());
BOOST_TEST(0 == boost_no_stringstream::test()); BOOST_TEST(0 == boost_no_stringstream::test());
BOOST_TEST(0 == boost_no_unreachable_return_detection::test());
BOOST_TEST(0 == boost_no_pointer_to_member_const::test()); BOOST_TEST(0 == boost_no_pointer_to_member_const::test());
BOOST_TEST(0 == boost_no_private_in_aggregate::test()); BOOST_TEST(0 == boost_no_private_in_aggregate::test());
BOOST_TEST(0 == boost_no_template_partial_specialization::test()); BOOST_TEST(0 == boost_no_template_partial_specialization::test());

35
test/no_ret_det_fail.cpp Normal file
View File

@@ -0,0 +1,35 @@
// (C) Copyright Boost.org 1999. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// Test file for macro BOOST_NO_UNREACHABLE_RETURN_DETECTION
// This file should not compile, if it does then
// BOOST_NO_UNREACHABLE_RETURN_DETECTION need not be defined.
// see boost_no_ret_det.cxx for more details
// Do not edit this file, it was generated automatically by
// ../tools/generate from boost_no_ret_det.cxx on
// Mon Dec 9 12:06:12 2002
// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif
#include <boost/config.hpp>
#include "test.hpp"
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
#include "boost_no_ret_det.cxx"
#else
#error "this file should not compile"
#endif
int cpp_main( int, char *[] )
{
return boost_no_unreachable_return_detection::test();
}

35
test/no_ret_det_pass.cpp Normal file
View File

@@ -0,0 +1,35 @@
// (C) Copyright Boost.org 1999. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
// Test file for macro BOOST_NO_UNREACHABLE_RETURN_DETECTION
// This file should compile, if it does not then
// BOOST_NO_UNREACHABLE_RETURN_DETECTION needs to be defined.
// see boost_no_ret_det.cxx for more details
// Do not edit this file, it was generated automatically by
// ../tools/generate from boost_no_ret_det.cxx on
// Mon Dec 9 12:06:12 2002
// Must not have BOOST_ASSERT_CONFIG set; it defeats
// the objective of this file:
#ifdef BOOST_ASSERT_CONFIG
# undef BOOST_ASSERT_CONFIG
#endif
#include <boost/config.hpp>
#include "test.hpp"
#ifndef BOOST_NO_UNREACHABLE_RETURN_DETECTION
#include "boost_no_ret_det.cxx"
#else
namespace boost_no_unreachable_return_detection = empty_boost;
#endif
int cpp_main( int, char *[] )
{
return boost_no_unreachable_return_detection::test();
}