Compare commits

...

38 Commits

Author SHA1 Message Date
Peter Dimov 6f162555a3 Third try for clang-win 2018-07-09 19:34:55 +03:00
Peter Dimov 6dcde20c14 Another try for clang-win 2018-07-09 19:18:42 +03:00
Peter Dimov 0333af2a72 Try clang-win with a user-config 2018-07-09 18:48:50 +03:00
Peter Dimov 971b46d038 Try clang-cl.exe again, with msvc without a custom version 2018-07-09 18:27:48 +03:00
Peter Dimov e74205d2a1 Quote USER_CONFIG 2018-07-09 18:03:09 +03:00
Peter Dimov d77d6460ab Try using msvc.jam with clang-cl.exe 2018-07-09 17:58:00 +03:00
Peter Dimov 66631f95d4 Try clang-win 2018-07-09 13:05:58 +03:00
Peter Dimov 7da0eed2fe Disable constexpr on Clang/Win 2018-07-09 12:48:12 +03:00
Peter Dimov 6abf6c7e89 Disable 03/11 tests under Clang/Win 2018-07-09 12:30:18 +03:00
Peter Dimov 6b638df0c1 Add Clang to Appveyor 2018-07-09 10:51:32 +03:00
Peter Dimov 9e039cfaf9 Fix dllexport mismatch errors under clang++ 2018-06-29 05:39:42 +03:00
Peter Dimov 084d8e119e Update g++ workaround to exclude 7.4/8.1 2018-06-29 03:56:56 +03:00
Peter Dimov 0d2aeead38 Update workarounds to cover g++ 8.1 2018-06-29 02:29:23 +03:00
Peter Dimov 73b2805d63 Add g++ 8, clang++ 6 to Travis 2018-06-29 00:42:31 +03:00
Peter Dimov 6a71483984 Work around ld: unrecognized option '--push-state--no-as-needed' 2018-05-04 15:47:28 +03:00
Peter Dimov 2b1aa524d9 Merge pull request #23 from boostorg/feature/constexpr
Make error_code and error_condition constexpr, as proposed in https://cplusplus.github.io/LWG/issue2992
2018-05-04 15:06:41 +03:00
Peter Dimov a9bb21507a Add Cygwin 64 to Appveyor 2018-03-09 05:12:03 +02:00
Peter Dimov d1f3d3b349 Merge branch 'develop' into feature/constexpr 2018-01-29 14:57:30 +02:00
Peter Dimov 35e3e22c7e Add BOOST_SYSTEM_CONSTEXPR to operator bool 2018-01-22 23:39:59 +02:00
Peter Dimov 7b94454e7c Merge branch 'develop' into feature/constexpr 2018-01-22 21:13:37 +02:00
Peter Dimov a413220f8d Add more constexpr tests 2018-01-22 19:43:28 +02:00
Peter Dimov 9f5272fa61 Install libstdc++-4.9 for clang++ 5.0 ubsan 2018-01-22 18:28:00 +02:00
Peter Dimov 19d5bf5f04 clang++ 3.8 and below requires a user-provided default constructor 2018-01-22 17:39:29 +02:00
Peter Dimov 9f5cbe223c Merge branch 'develop' into feature/constexpr 2018-01-22 08:07:54 +02:00
Peter Dimov a14074bafc Merge branch 'develop' into feature/constexpr 2018-01-22 07:19:19 +02:00
Peter Dimov 587ceaf739 Enable constexpr in header-only mode as well 2018-01-22 04:56:40 +02:00
Peter Dimov 8416ba067f Merge branch 'develop' into feature/constexpr 2018-01-22 03:20:23 +02:00
Peter Dimov 77817d8847 Fix MinGW link errors by properly exporting symbols 2018-01-22 02:20:01 +02:00
Peter Dimov fe28fa163c Merge branch 'develop' into feature/constexpr 2018-01-21 22:32:19 +02:00
Peter Dimov 61b4d8ef24 Fix variant=release link errors 2018-01-21 21:42:22 +02:00
Peter Dimov 3ba40116fe Merge branch 'develop' into feature/constexpr 2018-01-21 20:44:29 +02:00
Peter Dimov d837670627 Merge branch 'develop' into feature/constexpr 2018-01-21 19:55:18 +02:00
Peter Dimov f89fe0ea77 Merge branch 'develop' into feature/constexpr 2018-01-18 15:03:07 +02:00
Peter Dimov d0b3f59e63 Merge branch 'develop' into feature/constexpr 2018-01-16 16:12:18 +02:00
Peter Dimov 83ddde6b78 Disable constexpr on g++ 7/8 in C++17 mode due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835 2018-01-14 15:55:23 +02:00
Peter Dimov fe55a4a963 Make error_category::op==, !=, < nonmembers (a non-literal class can't have constexpr members acc. to g++) 2018-01-14 08:49:25 +02:00
Peter Dimov de5a0cf3ca Install libstdc++-4.9 for clang 4.0, 5.0 too 2018-01-14 07:56:11 +02:00
Peter Dimov 7b6dcf6ac6 Make error_code, error_condition literal if C++14 constexpr is available 2018-01-14 07:24:00 +02:00
7 changed files with 392 additions and 117 deletions
+27 -2
View File
@@ -109,7 +109,7 @@ matrix:
- os: linux
compiler: g++-7
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
@@ -117,6 +117,16 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
@@ -202,6 +212,7 @@ matrix:
apt:
packages:
- clang-4.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
@@ -213,6 +224,7 @@ matrix:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
@@ -224,10 +236,23 @@ matrix:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
@@ -264,7 +289,7 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on}
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
+12
View File
@@ -14,6 +14,10 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: clang-win
CLANG_WIN: 1
USER_CONFIG: "using clang-win : : clang-cl.exe : <compatibility>vc14 ;"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
@@ -36,6 +40,13 @@ environment:
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
@@ -70,4 +81,5 @@ build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%USER_CONFIG%" == "" echo %USER_CONFIG% > %HOMEDRIVE%%HOMEPATH%\user-config.jam
- b2 -j3 libs/system/test toolset=%TOOLSET% variant=debug,release %CXXSTD%
+54 -54
View File
@@ -35,45 +35,22 @@
//--------------------------------------------------------------------------------------//
namespace boost
{
namespace system
{
namespace system
{
namespace detail
{
// standard error categories -------------------------------------------------------//
class generic_error_category : public error_category
{
public:
generic_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
};
class system_error_category : public error_category
{
public:
system_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
};
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_INLINE inline
# define BOOST_SYSTEM_DECL_ inline
#else
# define BOOST_SYSTEM_INLINE
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
// generic_error_category implementation ---------------------------------//
BOOST_SYSTEM_INLINE const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
BOOST_SYSTEM_INLINE std::string generic_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string generic_error_category::message( int ev ) const
{
using namespace boost::system::errc;
#if defined(__PGI)
@@ -166,12 +143,7 @@ namespace detail
}
// system_error_category implementation --------------------------------------------//
BOOST_SYSTEM_INLINE const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
BOOST_SYSTEM_INLINE error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_DECL_ error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_NOEXCEPT
{
using namespace boost::system::errc;
@@ -376,13 +348,13 @@ namespace detail
# if !defined( BOOST_WINDOWS_API )
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
{
return generic_category().message( ev );
}
# else
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
{
#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS)
std::wstring buf(128, wchar_t());
@@ -461,7 +433,7 @@ namespace detail
}
# endif
#undef BOOST_SYSTEM_INLINE
#undef BOOST_SYSTEM_DECL_
} // namespace detail
@@ -474,23 +446,51 @@ namespace detail
// address for comparison purposes
# endif
# ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_LINKAGE inline
# else
# define BOOST_SYSTEM_LINKAGE BOOST_SYSTEM_DECL
# endif
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_const;
return system_category_const;
}
// defined in error_code.hpp
BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_const;
return generic_category_const;
}
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return generic_category_instance;
}
} // namespace detail
#else
namespace detail
{
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
} // namespace detail
#endif
} // namespace system
} // namespace system
} // namespace boost
+228 -58
View File
@@ -39,6 +39,27 @@
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
#endif
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
# define BOOST_SYSTEM_HAS_CONSTEXPR
#endif
#if defined(__GNUC__) && (__GNUC__ == 7 && __GNUC_MINOR__ < 4) && __cplusplus >= 201700L
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835
# undef BOOST_SYSTEM_HAS_CONSTEXPR
#endif
#if defined(__clang__) && defined(_MSC_VER) && defined(_CPPLIB_VER)
// Clang on Windows with MSVC headers, the constructor of std::error_category
// is not constexpr at least up to VS2017 15.7.x (_MSVC_STL_UPDATE 201803)
# undef BOOST_SYSTEM_HAS_CONSTEXPR
#endif
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
# define BOOST_SYSTEM_CONSTEXPR constexpr
#else
# define BOOST_SYSTEM_CONSTEXPR
#endif
namespace boost
{
namespace system
@@ -186,31 +207,6 @@ namespace boost
// --------------------------------------------------------------------------------//
class error_category;
// predefined error categories ---------------------------------------------------//
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#else
BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#endif
// deprecated synonyms ------------------------------------------------------------//
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
inline const error_category & get_system_category() { return system_category(); }
inline const error_category & get_generic_category() { return generic_category(); }
inline const error_category & get_posix_category() { return generic_category(); }
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
= system_category();
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
// 'this' : used in base member initializer list
@@ -233,7 +229,7 @@ namespace boost
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
{
}
@@ -259,7 +255,7 @@ namespace boost
public:
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
operator std::error_category const & () const BOOST_SYSTEM_NOEXCEPT
{
@@ -284,7 +280,7 @@ namespace boost
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
{
}
@@ -310,7 +306,7 @@ namespace boost
public:
error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {}
#endif
@@ -326,19 +322,193 @@ namespace boost
BOOST_SYSTEM_NOEXCEPT;
inline virtual bool equivalent( const error_code & code,
int condition ) const BOOST_SYSTEM_NOEXCEPT;
bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT
{ return this == &rhs; }
bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT
{ return this != &rhs; }
bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT
{ return std::less<const error_category*>()( this, &rhs ); }
};
BOOST_SYSTEM_CONSTEXPR inline bool operator==( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return &lhs == &rhs; }
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return &lhs != &rhs; }
inline bool operator<( const error_category & lhs,
const error_category & rhs ) BOOST_SYSTEM_NOEXCEPT
{ return std::less<const error_category*>()( &lhs, &rhs ); }
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// predefined error categories ---------------------------------------------------//
namespace detail
{
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_DECL_
#else
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
class generic_error_category: public error_category
{
public:
// clang++ 3.8 and below: initialization of const object
// requires a user-provided default constructor
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_SYSTEM_NOEXCEPT
{
}
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
};
class system_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_SYSTEM_NOEXCEPT
{
}
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
BOOST_SYSTEM_DECL_ error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
};
#undef BOOST_SYSTEM_DECL_
} // namespace detail
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
#endif
#endif
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
# if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct cat_holder
{
static system_error_category system_category_instance;
static generic_error_category generic_category_instance;
};
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT generic_error_category cat_holder<T>::generic_category_instance;
} // namespace detail
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::cat_holder<void>::system_category_instance;
}
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::cat_holder<void>::generic_category_instance;
}
# else
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
# endif
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
#if defined(BOOST_SYSTEM_SOURCE)
// clang++ requires a strictly matching declaration
BOOST_SYSTEM_DECL extern system_error_category system_category_instance;
BOOST_SYSTEM_DECL extern generic_error_category generic_category_instance;
#else
extern system_error_category system_category_instance;
extern generic_error_category generic_category_instance;
#endif
} // namespace detail
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::system_category_instance;
}
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::generic_category_instance;
}
#else
namespace detail
{
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT;
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT;
} // namespace detail
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::system_category_ncx();
}
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::generic_category_ncx();
}
#endif
// deprecated synonyms ------------------------------------------------------------//
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
inline const error_category & get_system_category() { return system_category(); }
inline const error_category & get_generic_category() { return generic_category(); }
inline const error_category & get_posix_category() { return generic_category(); }
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED
= generic_category();
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED
= system_category();
#endif
// class error_condition ---------------------------------------------------------//
// error_conditions are portable, error_codes are system or library specific
@@ -348,8 +518,8 @@ namespace boost
public:
// constructors:
error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
: m_val(val), m_cat(&cat) {}
template <class ErrorConditionEnum>
@@ -362,7 +532,7 @@ namespace boost
// modifiers:
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
@@ -377,20 +547,20 @@ namespace boost
return *this;
}
void clear() BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &generic_category();
}
// observers:
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
std::string message() const { return m_cat->message(value()); }
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val != 0;
}
@@ -400,12 +570,12 @@ namespace boost
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val == 0 ? 0 : unspecified_bool_true;
}
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
@@ -415,7 +585,7 @@ namespace boost
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
inline friend bool operator==( const error_condition & lhs,
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs,
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
@@ -458,8 +628,8 @@ namespace boost
public:
// constructors:
error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
: m_val(val), m_cat(&cat) {}
template <class ErrorCodeEnum>
@@ -471,7 +641,7 @@ namespace boost
}
// modifiers:
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
@@ -485,22 +655,22 @@ namespace boost
return *this;
}
void clear() BOOST_SYSTEM_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &system_category();
}
// observers:
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT
{ return m_cat->default_error_condition(value()); }
std::string message() const { return m_cat->message(value()); }
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val != 0;
}
@@ -510,12 +680,12 @@ namespace boost
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{
return m_val == 0 ? 0 : unspecified_bool_true;
}
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
@@ -523,7 +693,7 @@ namespace boost
#endif
// relationals:
inline friend bool operator==( const error_code & lhs,
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs,
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
@@ -596,13 +766,13 @@ namespace boost
{
// non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs,
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs,
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
inline bool operator!=( const error_condition & lhs,
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs,
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
+3 -1
View File
@@ -76,11 +76,12 @@ project
return $(result) ;
}
if [ os.environ UBSAN ]
if [ os.environ UBSAN ] || [ os.environ CLANG_WIN ]
{
rule system-run ( sources + )
{
# The 03/11 tests are ODR violations, no point running them under -fsanitize=undefined
# Clang on Windows uses MSVC headers, which don't parse under 03/11
return [ system-run- $(sources) ] ;
}
}
@@ -126,6 +127,7 @@ else
[ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ]
[ system-run before_main_test.cpp ]
[ run-fail throws_assign_fail.cpp ]
[ system-run- constexpr_test.cpp ]
;
# Quick (CI) test
+68
View File
@@ -0,0 +1,68 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
int main() {}
#else
using namespace boost::system;
constexpr error_code e1( 1, system_category() );
BOOST_STATIC_ASSERT( e1.value() == 1 );
BOOST_STATIC_ASSERT( e1.category() == system_category() );
BOOST_STATIC_ASSERT( e1 );
BOOST_STATIC_ASSERT( e1 == e1 );
constexpr error_code e2( 2, generic_category() );
BOOST_STATIC_ASSERT( e2.value() == 2 );
BOOST_STATIC_ASSERT( e2.category() == generic_category() );
BOOST_STATIC_ASSERT( e2 );
BOOST_STATIC_ASSERT( e2 == e2 );
#if !BOOST_WORKAROUND(BOOST_GCC, < 80200)
BOOST_STATIC_ASSERT( e1 != e2 );
#endif
constexpr error_code e3;
BOOST_STATIC_ASSERT( e3.value() == 0 );
BOOST_STATIC_ASSERT( e3.category() == system_category() );
BOOST_STATIC_ASSERT( !e3 );
BOOST_STATIC_ASSERT( e3 == e3 );
#if !BOOST_WORKAROUND(BOOST_GCC, < 80200)
BOOST_STATIC_ASSERT( e1 != e3 );
#endif
int main()
{
error_code e1_( 1, system_category() );
BOOST_TEST_EQ( e1, e1_ );
error_code e2_( 2, generic_category() );
BOOST_TEST_EQ( e2, e2_ );
error_code e3_;
BOOST_TEST_EQ( e3, e3_ );
return boost::report_errors();
}
#endif
-2
View File
@@ -38,7 +38,6 @@ static void test_generic_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
static void test_system_category()
@@ -47,7 +46,6 @@ static void test_system_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
int main()