catchable defects (#13626)
* allow defects to be caught even for --exceptions:goto (WIP) * implemented the new --panics:on|off switch; refs https://github.com/nim-lang/RFCs/issues/180 * new implementation for integer overflow checking * produce a warning if a user-defined exception type inherits from Exception directly * applied Timothee's suggestions; improved the documentation and replace the term 'checked runtime check' by 'panic' * fixes #13627 * don't inherit from Exception directly
This commit is contained in:
parent
14b2354b7d
commit
a6682de004
35 changed files with 441 additions and 142 deletions
|
|
@ -545,4 +545,26 @@ typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == siz
|
|||
#define NIM_CHECK_SIZE(typ, sz) \
|
||||
_Static_assert(sizeof(typ) == sz, "Nim & C disagree on type size")
|
||||
|
||||
/* these exist to make the codegen logic simpler */
|
||||
#define nimModInt(a, b, res) (((*res) = (a) % (b)), 0)
|
||||
#define nimModInt64(a, b, res) (((*res) = (a) % (b)), 0)
|
||||
|
||||
/* these exist because we cannot have .compilerProcs that are importc'ed
|
||||
by a different name */
|
||||
|
||||
#define nimAddInt64(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res)
|
||||
#define nimSubInt64(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res)
|
||||
#define nimMulInt64(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res)
|
||||
|
||||
#if NIM_INTBITS == 32
|
||||
#define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res)
|
||||
#define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
|
||||
#define nimMulInt(a, b, res) __builtin_smul_overflow(a, b, res)
|
||||
#else
|
||||
/* map it to the 'long long' variant */
|
||||
#define nimAddInt(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res)
|
||||
#define nimSubInt(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res)
|
||||
#define nimMulInt(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res)
|
||||
#endif
|
||||
|
||||
#endif /* NIMBASE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue