boost_no_ret_det.ipp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // (C) Copyright John Maddock 2001.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for the most recent version.
  6. // MACRO: BOOST_NO_UNREACHABLE_RETURN_DETECTION
  7. // TITLE: detection of unreachable returns
  8. // DESCRIPTION: If a return is unreachable, then no return
  9. // statement should be required, however some
  10. // compilers insist on it, while other issue a
  11. // bunch of warnings if it is in fact present.
  12. #if defined( BOOST_NO_EXCEPTIONS )
  13. # include <stdlib.h>
  14. #endif
  15. namespace boost_no_unreachable_return_detection{
  16. int checker()
  17. {
  18. #if defined( BOOST_NO_EXCEPTIONS ) && (!defined( _MSC_VER ) || defined(__clang__))
  19. abort();
  20. #else
  21. throw 0;
  22. #endif
  23. // no return statement: we don't ever get here...
  24. }
  25. int check = 0;
  26. int test()
  27. {
  28. if(check)
  29. return checker();
  30. return 0;
  31. }
  32. }