Debian Codegraph @

lib/_Noreturn.h

raw
1 /* A C macro for declaring that a function does not return.
2 Copyright (C) 2011-2026 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 /* The _Noreturn keyword of C11.
18 Do not use [[noreturn]], because with it the syntax
19 extern _Noreturn void func (...);
20 would not be valid; such a declaration would be valid only with 'extern'
21 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
22 AIX system header files and several gnulib header files use precisely
23 this syntax with 'extern'. So even though C23 deprecates _Noreturn,
24 it is currently more portable to prefer it to [[noreturn]].
25
26 Also, do not try to work around LLVM bug 59792 (clang 15 or earlier).
27 This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
28 though the workaround may generate many false-alarm warnings. */
29 #ifndef _Noreturn
30 # if ((!defined __cplusplus || defined __clang__) \
31 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
32 /* _Noreturn works as-is. */
33 # elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
34 || 0x5110 <= __SUNPRO_C)
35 /* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the
36 latter works, as 'gcc -std=gnu99 -Wpedantic' warns about _Noreturn. */
37 # define _Noreturn __attribute__ ((__noreturn__))
38 # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
39 # define _Noreturn __declspec (noreturn)
40 # else
41 # define _Noreturn
42 # endif
43 #endif