mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd: Mitigate __builtin_assume w/ side-effects diagnosed (arguably incorrect) and ignored.
This commit is contained in:
parent
8e983880f2
commit
3f82d32619
1 changed files with 9 additions and 3 deletions
|
@ -68,10 +68,16 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#if !defined(assume)
|
#if !defined(assume)
|
||||||
#if __has_builtin(__builtin_assume)
|
#if __has_builtin(__builtin_assume) && defined(__cplusplus)
|
||||||
#define assume(x) assert(x); __builtin_assume(x);
|
// If the expression is 'evaluated' (llvm) (which includes any
|
||||||
|
// function call not explicitly annotated pure, even when fully
|
||||||
|
// inlined) then the assume is diagnosed by -Wassume and ignored.
|
||||||
|
// Declaring the bool mitigates this.
|
||||||
|
#define assume(x) assert(x); ({ const bool y(x); __builtin_assume(y); })
|
||||||
|
#elif __has_builtin(__builtin_assume)
|
||||||
|
#define assume(x) assert(x); __builtin_assume(x)
|
||||||
#else
|
#else
|
||||||
#define assume(x) assert(x);
|
#define assume(x) assert(x)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue