BUILD: compiler: add a new statement "__unreachable()"
This statement is used as a hint for the compiler so that it knows that the location where it's placed cannot be reached. It will mostly be used after longjmp() or equivalent statements that deal with error processing and that the compiler doesn't know will not return on certain conditions, so that it doesn't complain about null dereferences on error paths.
This commit is contained in:
parent
e5f229e639
commit
8d26f02e69
|
@ -82,6 +82,18 @@
|
|||
*/
|
||||
#define __maybe_unused __attribute__((unused))
|
||||
|
||||
/* This allows gcc to know that some locations are never reached, for example
|
||||
* after a longjmp() in the Lua code, hence that some errors caught by such
|
||||
* methods cannot propagate further. This is important with gcc versions 6 and
|
||||
* above which can more aggressively detect null dereferences. The builtin
|
||||
* below was introduced in gcc 4.5, and before it we didn't care.
|
||||
*/
|
||||
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
#define __unreachable() __builtin_unreachable()
|
||||
#else
|
||||
#define __unreachable()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Gcc >= 3 provides the ability for the programme to give hints to the
|
||||
* compiler about what branch of an if is most likely to be taken. This
|
||||
|
|
Loading…
Reference in New Issue