diff options
| author | Paul Eggert | 2020-05-11 17:28:23 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-05-11 17:54:23 -0700 |
| commit | 00f0ad55cd7cbb71e42de0d52b7607ffb6a3c220 (patch) | |
| tree | c7ea55a573abdb8a1583d59ca38ef035e33978f7 /lib | |
| parent | dd0b910f1a9d08e65f59cc7ebc10fb6cd0fecfc9 (diff) | |
| download | emacs-00f0ad55cd7cbb71e42de0d52b7607ffb6a3c220.tar.gz emacs-00f0ad55cd7cbb71e42de0d52b7607ffb6a3c220.zip | |
Update from gnulib
This incorporates:
2020-05-11 careadlinkat: fix GCC 10 workaround
2020-05-10 careadlinkat: limit GCC workaround
2020-05-10 attribute: clarify list of attributes
2020-05-10 string: fix compilation error in C++ mode
2020-05-09 manywarnings: port to GCC 10.1
2020-05-09 careadlinkat: pacify -Wreturn-local-addr
2020-05-09 attribute: remove ATTRIBUTE_DEPRECATED
2020-05-09 attribute: Add comments
* lib/attribute.h, lib/careadlinkat.c, lib/string.in.h:
* lib/warn-on-use.h, m4/manywarnings.m4: Copy from Gnulib.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/attribute.h | 203 | ||||
| -rw-r--r-- | lib/careadlinkat.c | 38 | ||||
| -rw-r--r-- | lib/string.in.h | 26 | ||||
| -rw-r--r-- | lib/warn-on-use.h | 21 |
4 files changed, 234 insertions, 54 deletions
diff --git a/lib/attribute.h b/lib/attribute.h index c5919d97005..2836b99dad0 100644 --- a/lib/attribute.h +++ b/lib/attribute.h | |||
| @@ -20,39 +20,196 @@ | |||
| 20 | /* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* | 20 | /* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* |
| 21 | macros used within Gnulib. */ | 21 | macros used within Gnulib. */ |
| 22 | 22 | ||
| 23 | /* These attributes can be placed in two ways: | ||
| 24 | - At the start of a declaration (i.e. even before storage-class | ||
| 25 | specifiers!); then they apply to all entities that are declared | ||
| 26 | by the declaration. | ||
| 27 | - Immediately after the name of an entity being declared by the | ||
| 28 | declaration; then they apply to that entity only. */ | ||
| 29 | |||
| 23 | #ifndef _GL_ATTRIBUTE_H | 30 | #ifndef _GL_ATTRIBUTE_H |
| 24 | #define _GL_ATTRIBUTE_H | 31 | #define _GL_ATTRIBUTE_H |
| 25 | 32 | ||
| 26 | /* C2X standard attributes have macro names that do not begin with | 33 | |
| 27 | 'ATTRIBUTE_'. */ | 34 | /* This file defines two types of attributes: |
| 35 | * C2X standard attributes. These have macro names that do not begin with | ||
| 36 | 'ATTRIBUTE_'. | ||
| 37 | * Selected GCC attributes; see: | ||
| 38 | https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html | ||
| 39 | https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html | ||
| 40 | https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html | ||
| 41 | These names begin with 'ATTRIBUTE_' to avoid name clashes. */ | ||
| 42 | |||
| 43 | |||
| 44 | /* =============== Attributes for specific kinds of functions =============== */ | ||
| 45 | |||
| 46 | /* Attributes for functions that should not be used. */ | ||
| 47 | |||
| 48 | /* Warn if the entity is used. */ | ||
| 49 | /* Applies to: | ||
| 50 | - function, variable, | ||
| 51 | - struct, union, struct/union member, | ||
| 52 | - enumeration, enumeration item, | ||
| 53 | - typedef, | ||
| 54 | in C++ also: namespace, class, template specialization. */ | ||
| 28 | #define DEPRECATED _GL_ATTRIBUTE_DEPRECATED | 55 | #define DEPRECATED _GL_ATTRIBUTE_DEPRECATED |
| 29 | #define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH | ||
| 30 | #define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED | ||
| 31 | #define NODISCARD _GL_ATTRIBUTE_NODISCARD | ||
| 32 | 56 | ||
| 33 | /* Selected GCC attributes; see: | 57 | /* If a function call is not optimized way, warn with MSG. */ |
| 34 | https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html | 58 | /* Applies to: functions. */ |
| 35 | These names begin with 'ATTRIBUTE_' to avoid name clashes. */ | 59 | #define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg) |
| 36 | #define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args) | 60 | |
| 37 | #define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE | 61 | /* If a function call is not optimized way, report an error with MSG. */ |
| 38 | #define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL | 62 | /* Applies to: functions. */ |
| 39 | #define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD | ||
| 40 | #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST | ||
| 41 | #define ATTRIBUTE_DEPRECATED _GL_ATTRIBUTE_DEPRECATED | ||
| 42 | #define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg) | 63 | #define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg) |
| 43 | #define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE | 64 | |
| 44 | #define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec) | 65 | |
| 45 | #define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF | 66 | /* Attributes for memory-allocating functions. */ |
| 46 | #define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS | 67 | |
| 68 | /* The function returns a pointer to freshly allocated memory. */ | ||
| 69 | /* Applies to: functions. */ | ||
| 47 | #define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC | 70 | #define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC |
| 48 | #define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE | 71 | |
| 72 | /* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function | ||
| 73 | is the size of the returned memory block. | ||
| 74 | ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments | ||
| 75 | to determine the size of the returned memory block. */ | ||
| 76 | /* Applies to: function, pointer to function, function types. */ | ||
| 77 | #define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args) | ||
| 78 | |||
| 79 | |||
| 80 | /* Attributes for variadic functions. */ | ||
| 81 | |||
| 82 | /* The variadic function expects a trailing NULL argument. | ||
| 83 | ATTRIBUTE_SENTINEL () - The last argument is NULL. | ||
| 84 | ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ | ||
| 85 | /* Applies to: functions. */ | ||
| 86 | #define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos) | ||
| 87 | |||
| 88 | |||
| 89 | /* ================== Attributes for compiler diagnostics ================== */ | ||
| 90 | |||
| 91 | /* Attributes that help the compiler diagnose programmer mistakes. | ||
| 92 | Some of them may also help for some compiler optimizations. */ | ||
| 93 | |||
| 94 | /* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) - | ||
| 95 | The STRING-INDEXth function argument is a format string of style | ||
| 96 | ARCHETYPE, which is one of: | ||
| 97 | printf, gnu_printf | ||
| 98 | scanf, gnu_scanf, | ||
| 99 | strftime, gnu_strftime, | ||
| 100 | strfmon, | ||
| 101 | or the same thing prefixed and suffixed with '__'. | ||
| 102 | If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK | ||
| 103 | are suitable for the format string. */ | ||
| 104 | /* Applies to: functions. */ | ||
| 105 | #define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec) | ||
| 106 | |||
| 107 | /* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL. | ||
| 108 | ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */ | ||
| 109 | /* Applies to: functions. */ | ||
| 49 | #define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) | 110 | #define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) |
| 111 | |||
| 112 | /* The function's return value is a non-NULL pointer. */ | ||
| 113 | /* Applies to: functions. */ | ||
| 114 | #define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL | ||
| 115 | |||
| 116 | /* Warn if the caller does not use the return value, | ||
| 117 | unless the caller uses something like ignore_value. */ | ||
| 118 | /* Applies to: function, enumeration, class. */ | ||
| 119 | #define NODISCARD _GL_ATTRIBUTE_NODISCARD | ||
| 120 | |||
| 121 | |||
| 122 | /* Attributes that disable false alarms when the compiler diagnoses | ||
| 123 | programmer "mistakes". */ | ||
| 124 | |||
| 125 | /* Do not warn if the entity is not used. */ | ||
| 126 | /* Applies to: | ||
| 127 | - function, variable, | ||
| 128 | - struct, union, struct/union member, | ||
| 129 | - enumeration, enumeration item, | ||
| 130 | - typedef, | ||
| 131 | in C++ also: class. */ | ||
| 132 | #define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED | ||
| 133 | |||
| 134 | /* The contents of a character array is not meant to be NUL-terminated. */ | ||
| 135 | /* Applies to: struct/union members and variables that are arrays of element | ||
| 136 | type '[[un]signed] char'. */ | ||
| 50 | #define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING | 137 | #define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING |
| 138 | |||
| 139 | /* Do not warn if control flow falls through to the immediately | ||
| 140 | following 'case' or 'default' label. */ | ||
| 141 | /* Applies to: Empty statement (;), inside a 'switch' statement. */ | ||
| 142 | #define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH | ||
| 143 | |||
| 144 | |||
| 145 | /* ================== Attributes for debugging information ================== */ | ||
| 146 | |||
| 147 | /* Attributes regarding debugging information emitted by the compiler. */ | ||
| 148 | |||
| 149 | /* Omit the function from stack traces when debugging. */ | ||
| 150 | /* Applies to: function. */ | ||
| 151 | #define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL | ||
| 152 | |||
| 153 | /* Make the entity visible to debuggers etc., even with '-fwhole-program'. */ | ||
| 154 | /* Applies to: functions, variables. */ | ||
| 155 | #define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE | ||
| 156 | |||
| 157 | |||
| 158 | /* ========== Attributes that mainly direct compiler optimizations ========== */ | ||
| 159 | |||
| 160 | /* The function does not throw exceptions. */ | ||
| 161 | /* Applies to: functions. */ | ||
| 51 | #define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW | 162 | #define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW |
| 52 | #define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED | 163 | |
| 164 | /* Do not inline the function. */ | ||
| 165 | /* Applies to: functions. */ | ||
| 166 | #define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE | ||
| 167 | |||
| 168 | /* Always inline the function, and report an error if the compiler | ||
| 169 | cannot inline. */ | ||
| 170 | /* Applies to: function. */ | ||
| 171 | #define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE | ||
| 172 | |||
| 173 | /* The function does not affect observable state, and always returns a value. | ||
| 174 | Compilers can omit duplicate calls with the same arguments if | ||
| 175 | observable state is not changed between calls. (This attribute is | ||
| 176 | looser than ATTRIBUTE_CONST.) */ | ||
| 177 | /* Applies to: functions. */ | ||
| 53 | #define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE | 178 | #define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE |
| 54 | #define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL | 179 | |
| 55 | #define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos) | 180 | /* The function neither depends on nor affects observable state, |
| 56 | #define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg) | 181 | and always returns a value. Compilers can omit duplicate calls with |
| 182 | the same arguments. (This attribute is stricter than ATTRIBUTE_PURE.) */ | ||
| 183 | /* Applies to: functions. */ | ||
| 184 | #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST | ||
| 185 | |||
| 186 | /* The function is rarely executed. */ | ||
| 187 | /* Applies to: functions. */ | ||
| 188 | #define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD | ||
| 189 | |||
| 190 | /* If called from some other compilation unit, the function executes | ||
| 191 | code from that unit only by return or by exception handling, | ||
| 192 | letting the compiler optimize that unit more aggressively. */ | ||
| 193 | /* Applies to: functions. */ | ||
| 194 | #define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF | ||
| 195 | |||
| 196 | /* For struct members: The member has the smallest possible alignment. | ||
| 197 | For struct, union, class: All members have the smallest possible alignment, | ||
| 198 | minimizing the memory required. */ | ||
| 199 | /* Applies to: struct members, struct, union, | ||
| 200 | in C++ also: class. */ | ||
| 201 | #define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED | ||
| 202 | |||
| 203 | |||
| 204 | /* ================ Attributes that make invalid code valid ================ */ | ||
| 205 | |||
| 206 | /* Attributes that prevent fatal compiler optimizations for code that is not | ||
| 207 | fully ISO C compliant. */ | ||
| 208 | |||
| 209 | /* Pointers to the type may point to the same storage as pointers to | ||
| 210 | other types, thus disabling strict aliasing optimization. */ | ||
| 211 | /* Applies to: types. */ | ||
| 212 | #define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS | ||
| 213 | |||
| 57 | 214 | ||
| 58 | #endif /* _GL_ATTRIBUTE_H */ | 215 | #endif /* _GL_ATTRIBUTE_H */ |
diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c index 1effdb78451..1aa04363dac 100644 --- a/lib/careadlinkat.c +++ b/lib/careadlinkat.c | |||
| @@ -72,23 +72,38 @@ careadlinkat (int fd, char const *filename, | |||
| 72 | SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; | 72 | SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; |
| 73 | char stack_buf[1024]; | 73 | char stack_buf[1024]; |
| 74 | 74 | ||
| 75 | #if (defined GCC_LINT || defined lint) && _GL_GNUC_PREREQ (10, 1) | ||
| 76 | /* Pacify preadlinkat without creating a pointer to the stack | ||
| 77 | that a broken gcc -Wreturn-local-addr would cry wolf about. See: | ||
| 78 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044 | ||
| 79 | This workaround differs from the mainline code, but | ||
| 80 | no other way to pacify GCC 10.1.0 is known; even an explicit | ||
| 81 | #pragma does not pacify GCC. When the GCC bug is fixed this | ||
| 82 | workaround should be limited to the broken GCC versions. */ | ||
| 83 | # define WORK_AROUND_GCC_BUG_95044 | ||
| 84 | #endif | ||
| 85 | |||
| 75 | if (! alloc) | 86 | if (! alloc) |
| 76 | alloc = &stdlib_allocator; | 87 | alloc = &stdlib_allocator; |
| 77 | 88 | ||
| 78 | if (! buffer_size) | 89 | if (!buffer) |
| 79 | { | 90 | { |
| 91 | #ifdef WORK_AROUND_GCC_BUG_95044 | ||
| 92 | buffer = alloc->allocate (sizeof stack_buf); | ||
| 93 | #else | ||
| 80 | /* Allocate the initial buffer on the stack. This way, in the | 94 | /* Allocate the initial buffer on the stack. This way, in the |
| 81 | common case of a symlink of small size, we get away with a | 95 | common case of a symlink of small size, we get away with a |
| 82 | single small malloc() instead of a big malloc() followed by a | 96 | single small malloc() instead of a big malloc() followed by a |
| 83 | shrinking realloc(). */ | 97 | shrinking realloc(). */ |
| 84 | buffer = stack_buf; | 98 | buffer = stack_buf; |
| 99 | #endif | ||
| 85 | buffer_size = sizeof stack_buf; | 100 | buffer_size = sizeof stack_buf; |
| 86 | } | 101 | } |
| 87 | 102 | ||
| 88 | buf = buffer; | 103 | buf = buffer; |
| 89 | buf_size = buffer_size; | 104 | buf_size = buffer_size; |
| 90 | 105 | ||
| 91 | do | 106 | while (buf) |
| 92 | { | 107 | { |
| 93 | /* Attempt to read the link into the current buffer. */ | 108 | /* Attempt to read the link into the current buffer. */ |
| 94 | ssize_t link_length = preadlinkat (fd, filename, buf, buf_size); | 109 | ssize_t link_length = preadlinkat (fd, filename, buf, buf_size); |
| @@ -117,19 +132,19 @@ careadlinkat (int fd, char const *filename, | |||
| 117 | 132 | ||
| 118 | if (buf == stack_buf) | 133 | if (buf == stack_buf) |
| 119 | { | 134 | { |
| 120 | char *b = (char *) alloc->allocate (link_size); | 135 | char *b = alloc->allocate (link_size); |
| 121 | buf_size = link_size; | 136 | buf_size = link_size; |
| 122 | if (! b) | 137 | if (! b) |
| 123 | break; | 138 | break; |
| 124 | memcpy (b, buf, link_size); | 139 | return memcpy (b, buf, link_size); |
| 125 | buf = b; | ||
| 126 | } | 140 | } |
| 127 | else if (link_size < buf_size && buf != buffer && alloc->reallocate) | 141 | |
| 142 | if (link_size < buf_size && buf != buffer && alloc->reallocate) | ||
| 128 | { | 143 | { |
| 129 | /* Shrink BUF before returning it. */ | 144 | /* Shrink BUF before returning it. */ |
| 130 | char *b = (char *) alloc->reallocate (buf, link_size); | 145 | char *b = alloc->reallocate (buf, link_size); |
| 131 | if (b) | 146 | if (b) |
| 132 | buf = b; | 147 | return b; |
| 133 | } | 148 | } |
| 134 | 149 | ||
| 135 | return buf; | 150 | return buf; |
| @@ -138,8 +153,8 @@ careadlinkat (int fd, char const *filename, | |||
| 138 | if (buf != buffer) | 153 | if (buf != buffer) |
| 139 | alloc->free (buf); | 154 | alloc->free (buf); |
| 140 | 155 | ||
| 141 | if (buf_size <= buf_size_max / 2) | 156 | if (buf_size < buf_size_max / 2) |
| 142 | buf_size *= 2; | 157 | buf_size = 2 * buf_size + 1; |
| 143 | else if (buf_size < buf_size_max) | 158 | else if (buf_size < buf_size_max) |
| 144 | buf_size = buf_size_max; | 159 | buf_size = buf_size_max; |
| 145 | else if (buf_size_max < SIZE_MAX) | 160 | else if (buf_size_max < SIZE_MAX) |
| @@ -149,9 +164,8 @@ careadlinkat (int fd, char const *filename, | |||
| 149 | } | 164 | } |
| 150 | else | 165 | else |
| 151 | break; | 166 | break; |
| 152 | buf = (char *) alloc->allocate (buf_size); | 167 | buf = alloc->allocate (buf_size); |
| 153 | } | 168 | } |
| 154 | while (buf); | ||
| 155 | 169 | ||
| 156 | if (alloc->die) | 170 | if (alloc->die) |
| 157 | alloc->die (buf_size); | 171 | alloc->die (buf_size); |
diff --git a/lib/string.in.h b/lib/string.in.h index 96e132f37d7..a08e7057fbd 100644 --- a/lib/string.in.h +++ b/lib/string.in.h | |||
| @@ -334,9 +334,10 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " | |||
| 334 | GB18030 and the character to be searched is a digit. */ | 334 | GB18030 and the character to be searched is a digit. */ |
| 335 | # undef strchr | 335 | # undef strchr |
| 336 | /* Assume strchr is always declared. */ | 336 | /* Assume strchr is always declared. */ |
| 337 | _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | 337 | _GL_WARN_ON_USE_CXX (strchr, const char *, (const char *, int), |
| 338 | "in some multibyte locales - " | 338 | "strchr cannot work correctly on character strings " |
| 339 | "use mbschr if you care about internationalization"); | 339 | "in some multibyte locales - " |
| 340 | "use mbschr if you care about internationalization"); | ||
| 340 | #endif | 341 | #endif |
| 341 | 342 | ||
| 342 | /* Find the first occurrence of C in S or the final NUL byte. */ | 343 | /* Find the first occurrence of C in S or the final NUL byte. */ |
| @@ -528,15 +529,17 @@ _GL_CXXALIASWARN (strpbrk); | |||
| 528 | locale encoding is GB18030 and one of the characters to be searched is a | 529 | locale encoding is GB18030 and one of the characters to be searched is a |
| 529 | digit. */ | 530 | digit. */ |
| 530 | # undef strpbrk | 531 | # undef strpbrk |
| 531 | _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " | 532 | _GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *), |
| 532 | "in multibyte locales - " | 533 | "strpbrk cannot work correctly on character strings " |
| 533 | "use mbspbrk if you care about internationalization"); | 534 | "in multibyte locales - " |
| 535 | "use mbspbrk if you care about internationalization"); | ||
| 534 | # endif | 536 | # endif |
| 535 | #elif defined GNULIB_POSIXCHECK | 537 | #elif defined GNULIB_POSIXCHECK |
| 536 | # undef strpbrk | 538 | # undef strpbrk |
| 537 | # if HAVE_RAW_DECL_STRPBRK | 539 | # if HAVE_RAW_DECL_STRPBRK |
| 538 | _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " | 540 | _GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *), |
| 539 | "use gnulib module strpbrk for portability"); | 541 | "strpbrk is unportable - " |
| 542 | "use gnulib module strpbrk for portability"); | ||
| 540 | # endif | 543 | # endif |
| 541 | #endif | 544 | #endif |
| 542 | 545 | ||
| @@ -555,9 +558,10 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " | |||
| 555 | GB18030 and the character to be searched is a digit. */ | 558 | GB18030 and the character to be searched is a digit. */ |
| 556 | # undef strrchr | 559 | # undef strrchr |
| 557 | /* Assume strrchr is always declared. */ | 560 | /* Assume strrchr is always declared. */ |
| 558 | _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " | 561 | _GL_WARN_ON_USE_CXX (strrchr, const char *, (const char *, int), |
| 559 | "in some multibyte locales - " | 562 | "strrchr cannot work correctly on character strings " |
| 560 | "use mbsrchr if you care about internationalization"); | 563 | "in some multibyte locales - " |
| 564 | "use mbsrchr if you care about internationalization"); | ||
| 561 | #endif | 565 | #endif |
| 562 | 566 | ||
| 563 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. | 567 | /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. |
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h index 1be2cbb9570..23c10fdd122 100644 --- a/lib/warn-on-use.h +++ b/lib/warn-on-use.h | |||
| @@ -100,23 +100,28 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use | |||
| 100 | #endif | 100 | #endif |
| 101 | 101 | ||
| 102 | /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") | 102 | /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") |
| 103 | is like _GL_WARN_ON_USE (function, "string"), except that the function is | 103 | is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the |
| 104 | declared with the given prototype, consisting of return type, parameters, | 104 | function is declared with the given prototype, consisting of return type, |
| 105 | and attributes. | 105 | parameters, and attributes. |
| 106 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | 106 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does |
| 107 | not work in this case. */ | 107 | not work in this case. */ |
| 108 | #ifndef _GL_WARN_ON_USE_CXX | 108 | #ifndef _GL_WARN_ON_USE_CXX |
| 109 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | 109 | # if !defined __cplusplus |
| 110 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | 110 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
| 111 | _GL_WARN_ON_USE (function, msg) | ||
| 112 | # else | ||
| 113 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
| 114 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||
| 111 | extern rettype function parameters_and_attributes \ | 115 | extern rettype function parameters_and_attributes \ |
| 112 | __attribute__ ((__warning__ (msg))) | 116 | __attribute__ ((__warning__ (msg))) |
| 113 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | 117 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
| 114 | /* Verify the existence of the function. */ | 118 | /* Verify the existence of the function. */ |
| 115 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | 119 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
| 116 | extern rettype function parameters_and_attributes | 120 | extern rettype function parameters_and_attributes |
| 117 | # else /* Unsupported. */ | 121 | # else /* Unsupported. */ |
| 118 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | 122 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
| 119 | _GL_WARN_EXTERN_C int _gl_warn_on_use | 123 | _GL_WARN_EXTERN_C int _gl_warn_on_use |
| 124 | # endif | ||
| 120 | # endif | 125 | # endif |
| 121 | #endif | 126 | #endif |
| 122 | 127 | ||