Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / m4 / extern-inline.m4
CommitLineData
a512b375
JB
1dnl 'extern inline' a la ISO C99.
2
c0c3707f 3dnl Copyright 2012-2019 Free Software Foundation, Inc.
a512b375
JB
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_EXTERN_INLINE],
9[
10 AH_VERBATIM([extern_inline],
4a626d0a
PA
11[/* Please see the Gnulib manual for how to use these macros.
12
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see
c0c3707f 14 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
4a626d0a
PA
15
16 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
21
22 Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
23 on configurations that mistakenly use 'static inline' to implement
24 functions or macros in standard C headers like <ctype.h>. For example,
25 if isdigit is mistakenly implemented via a static inline function,
26 a program containing an extern inline function that calls isdigit
27 may not work since the C standard prohibits extern inline functions
c0c3707f
CB
28 from calling static functions (ISO C 99 section 6.7.4.(3).
29 This bug is known to occur on:
4a626d0a
PA
30
31 OS X 10.8 and earlier; see:
c0c3707f 32 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
4a626d0a
PA
33
34 DragonFly; see
c0c3707f 35 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log
4a626d0a
PA
36
37 FreeBSD; see:
c0c3707f 38 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
4a626d0a
PA
39
40 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
c0c3707f
CB
41 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
42 Assume DragonFly and FreeBSD will be similar.
43
44 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
45 inline semantics, unless -fgnu89-inline is used. It defines a macro
46 __GNUC_STDC_INLINE__ to indicate this situation or a macro
47 __GNUC_GNU_INLINE__ to indicate the opposite situation.
48 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
49 semantics but warns, unless -fgnu89-inline is used:
50 warning: C99 inline functions are not supported; using GNU89
51 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
52 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
53 */
4a626d0a
PA
54#if (((defined __APPLE__ && defined __MACH__) \
55 || defined __DragonFly__ || defined __FreeBSD__) \
56 && (defined __header_inline \
57 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
58 && ! defined __clang__) \
59 : ((! defined _DONT_USE_CTYPE_INLINE_ \
60 && (defined __GNUC__ || defined __cplusplus)) \
61 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
62 && defined __GNUC__ && ! defined __cplusplus))))
63# define _GL_EXTERN_INLINE_STDHEADER_BUG
64#endif
a512b375
JB
65#if ((__GNUC__ \
66 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
4a626d0a
PA
67 : (199901L <= __STDC_VERSION__ \
68 && !defined __HP_cc \
49e4877c 69 && !defined __PGI \
4a626d0a
PA
70 && !(defined __SUNPRO_C && __STDC__))) \
71 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
a512b375
JB
72# define _GL_INLINE inline
73# define _GL_EXTERN_INLINE extern inline
4a626d0a
PA
74# define _GL_EXTERN_INLINE_IN_USE
75#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
76 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
77# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
a512b375
JB
78 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
79# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
80# else
81# define _GL_INLINE extern inline
82# endif
83# define _GL_EXTERN_INLINE extern
4a626d0a 84# define _GL_EXTERN_INLINE_IN_USE
a512b375
JB
85#else
86# define _GL_INLINE static _GL_UNUSED
87# define _GL_EXTERN_INLINE static _GL_UNUSED
88#endif
89
4a626d0a
PA
90/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
91 suppress bogus "no previous prototype for 'FOO'"
92 and "no previous declaration for 'FOO'" diagnostics,
93 when FOO is an inline function in the header; see
94 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
95 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
96#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
a512b375
JB
97# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
98# define _GL_INLINE_HEADER_CONST_PRAGMA
99# else
100# define _GL_INLINE_HEADER_CONST_PRAGMA \
101 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
102# endif
103# define _GL_INLINE_HEADER_BEGIN \
104 _Pragma ("GCC diagnostic push") \
105 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
106 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
107 _GL_INLINE_HEADER_CONST_PRAGMA
108# define _GL_INLINE_HEADER_END \
109 _Pragma ("GCC diagnostic pop")
110#else
111# define _GL_INLINE_HEADER_BEGIN
112# define _GL_INLINE_HEADER_END
113#endif])
114])
This page took 0.595289 seconds and 4 git commands to generate.