mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12906 from kjbracey-arm/chrono_asserts
Work around C++14 assert problempull/12959/head
commit
f13db5fa76
|
@ -19,6 +19,7 @@
|
|||
#ifndef __MBED_CHRONO_H__
|
||||
#define __MBED_CHRONO_H__
|
||||
|
||||
#include "mbed_toolchain.h"
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
#include <ratio>
|
||||
|
@ -85,10 +86,7 @@ inline namespace chrono_literals {
|
|||
constexpr chrono::deciseconds operator "" _ds(unsigned long long x)
|
||||
{
|
||||
chrono::deciseconds::rep val = static_cast<chrono::deciseconds::rep>(x);
|
||||
if (val < 0) {
|
||||
assert(false);
|
||||
}
|
||||
assert(static_cast<unsigned long long>(val) == x);
|
||||
assert(val >= 0 && static_cast<unsigned long long>(val) == x);
|
||||
return chrono::deciseconds(val);
|
||||
}
|
||||
|
||||
|
@ -106,10 +104,7 @@ constexpr chrono::deciseconds operator "" _ds(unsigned long long x)
|
|||
constexpr chrono::centiseconds operator "" _cs(unsigned long long x)
|
||||
{
|
||||
chrono::centiseconds::rep val = static_cast<chrono::centiseconds::rep>(x);
|
||||
if (val < 0) {
|
||||
assert(false);
|
||||
}
|
||||
assert(static_cast<unsigned long long>(val) == x);
|
||||
assert(val >= 0 && static_cast<unsigned long long>(val) == x);
|
||||
return chrono::centiseconds(val);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,15 @@
|
|||
#define __error_t_defined 1
|
||||
#endif
|
||||
|
||||
/* Work around ARM Compiler 6 bug - assert does not work in constexpr
|
||||
* functions unless you stop it from using its __promise built-in.
|
||||
*/
|
||||
#ifdef __ARMCC_VERSION
|
||||
#ifndef __DO_NOT_LINK_PROMISE_WITH_ASSERT
|
||||
#define __DO_NOT_LINK_PROMISE_WITH_ASSERT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Warning for unsupported compilers
|
||||
#if !defined(__GNUC__) /* GCC */ \
|
||||
&& !defined(__clang__) /* LLVM/Clang */ \
|
||||
|
|
Loading…
Reference in New Issue