| 1 | /* A C macro for declaring that a function does not return. |
| 2 | Copyright (C) 2011-2023 Free Software Foundation, Inc. |
| 3 | |
| 4 | This program is free software: you can redistribute it and/or modify it |
| 5 | under the terms of the GNU Lesser General Public License as published |
| 6 | by the Free Software Foundation; either version 2 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public License |
| 15 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 | |
| 17 | #ifndef _Noreturn |
| 18 | # if (defined __cplusplus \ |
| 19 | && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ |
| 20 | || (defined _MSC_VER && 1900 <= _MSC_VER)) \ |
| 21 | && 0) |
| 22 | /* [[noreturn]] is not practically usable, because with it the syntax |
| 23 | extern _Noreturn void func (...); |
| 24 | would not be valid; such a declaration would only be valid with 'extern' |
| 25 | and '_Noreturn' swapped, or without the 'extern' keyword. However, some |
| 26 | AIX system header files and several gnulib header files use precisely |
| 27 | this syntax with 'extern'. */ |
| 28 | # define _Noreturn [[noreturn]] |
| 29 | # elif (defined __clang__ && __clang_major__ < 16 \ |
| 30 | && defined _GL_WORK_AROUND_LLVM_BUG_59792) |
| 31 | /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around |
| 32 | that rare LLVM bug, though you may get many false-alarm warnings. */ |
| 33 | # define _Noreturn |
| 34 | # elif ((!defined __cplusplus || defined __clang__) \ |
| 35 | && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ |
| 36 | || (!defined __STRICT_ANSI__ \ |
| 37 | && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ |
| 38 | || (defined __apple_build_version__ \ |
| 39 | ? 6000000 <= __apple_build_version__ \ |
| 40 | : 3 < __clang_major__ + (5 <= __clang_minor__)))))) |
| 41 | /* _Noreturn works as-is. */ |
| 42 | # elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \ |
| 43 | || 0x5110 <= __SUNPRO_C) |
| 44 | # define _Noreturn __attribute__ ((__noreturn__)) |
| 45 | # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) |
| 46 | # define _Noreturn __declspec (noreturn) |
| 47 | # else |
| 48 | # define _Noreturn |
| 49 | # endif |
| 50 | #endif |