Commit | Line | Data |
---|---|---|
c0c3707f CB |
1 | /* A C macro for declaring that a function does not return. |
2 | Copyright (C) 2011-2019 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 General Public License as published | |
6 | by the Free Software Foundation; either version 3 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 | General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU 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 __cplusplus || defined __clang__) \ | |
30 | && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ | |
31 | || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) | |
32 | /* _Noreturn works as-is. */ | |
33 | # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C | |
34 | # define _Noreturn __attribute__ ((__noreturn__)) | |
35 | # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) | |
36 | # define _Noreturn __declspec (noreturn) | |
37 | # else | |
38 | # define _Noreturn | |
39 | # endif | |
40 | #endif |