]> Savannah Git Hosting - gnulib.git/commitdiff
string: Fix build error in C++ mode with clang (regression from today).
authorBruno Haible <bruno@clisp.org>
Mon, 10 Aug 2020 01:17:06 +0000 (03:17 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 10 Aug 2020 01:17:06 +0000 (03:17 +0200)
* lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): Expect two rettype
parameters, one for GCC, one for clang.
* lib/c++defs.h (_GL_CXXALIASWARN1_2): Update.
* lib/string.in.h (strchr, strpbrk, strrchr): For clang, pass 'char *'
as return type.

ChangeLog
lib/c++defs.h
lib/string.in.h
lib/warn-on-use.h

index cced35ba8aa7145c8c373983faad161fc8196585..d249d3774091cab725d742e18a2e2c7f09ef8a74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-08-09  Bruno Haible  <bruno@clisp.org>
+
+       string: Fix build error in C++ mode with clang (regression from today).
+       * lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): Expect two rettype
+       parameters, one for GCC, one for clang.
+       * lib/c++defs.h (_GL_CXXALIASWARN1_2): Update.
+       * lib/string.in.h (strchr, strpbrk, strrchr): For clang, pass 'char *'
+       as return type.
+
 2020-08-09  Bruno Haible  <bruno@clisp.org>
 
        ftruncate: Use _chsize, not chsize.
index 75d6250ece16dca5ebc16e80d1165136c219b84f..cd56ea2c5c6c854e06b94f6285241c2608d7d7f6 100644 (file)
    we enable the warning only when not optimizing.  */
 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
-    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+    _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
                          "The symbol ::" #func " refers to the system function. " \
                          "Use " #namespace "::" #func " instead.")
 # else
index c18efa7c0a28806bf956a7c869cf422b1572d88e..ef702e3aba139259c8fe86c1886f7b7b271082c2 100644 (file)
@@ -329,7 +329,8 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
    GB18030 and the character to be searched is a digit.  */
 # undef strchr
 /* Assume strchr is always declared.  */
-_GL_WARN_ON_USE_CXX (strchr, const char *, (const char *, int),
+_GL_WARN_ON_USE_CXX (strchr,
+                     const char *, char *, (const char *, int),
                      "strchr cannot work correctly on character strings "
                      "in some multibyte locales - "
                      "use mbschr if you care about internationalization");
@@ -524,7 +525,8 @@ _GL_CXXALIASWARN (strpbrk);
    locale encoding is GB18030 and one of the characters to be searched is a
    digit.  */
 #  undef strpbrk
-_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
+_GL_WARN_ON_USE_CXX (strpbrk,
+                     const char *, char *, (const char *, const char *),
                      "strpbrk cannot work correctly on character strings "
                      "in multibyte locales - "
                      "use mbspbrk if you care about internationalization");
@@ -532,7 +534,8 @@ _GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
 #elif defined GNULIB_POSIXCHECK
 # undef strpbrk
 # if HAVE_RAW_DECL_STRPBRK
-_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
+_GL_WARN_ON_USE_CXX (strpbrk,
+                     const char *, char *, (const char *, const char *),
                      "strpbrk is unportable - "
                      "use gnulib module strpbrk for portability");
 # endif
@@ -553,7 +556,8 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
    GB18030 and the character to be searched is a digit.  */
 # undef strrchr
 /* Assume strrchr is always declared.  */
-_GL_WARN_ON_USE_CXX (strrchr, const char *, (const char *, int),
+_GL_WARN_ON_USE_CXX (strrchr,
+                     const char *, char *, (const char *, int),
                      "strrchr cannot work correctly on character strings "
                      "in some multibyte locales - "
                      "use mbsrchr if you care about internationalization");
index a39e3a394c73da27ef6c2aeb4fd1f5ef0833b4ac..5ff2163a254e38523b53fd66d10846224cc9a3c3 100644 (file)
@@ -106,33 +106,33 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
 # endif
 #endif
 
-/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
-   is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
+/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
+   is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
    function is declared with the given prototype, consisting of return type,
    parameters, and attributes.
    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
    not work in this case.  */
 #ifndef _GL_WARN_ON_USE_CXX
 # if !defined __cplusplus
-#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+#  define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
      _GL_WARN_ON_USE (function, msg)
 # else
 #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
-#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
-extern rettype function parameters_and_attributes \
+#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes \
   __attribute__ ((__warning__ (msg)))
 #  elif __clang_major__ >= 4
 /* Another compiler attribute is available in clang.  */
-#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
-extern rettype function parameters_and_attributes \
+#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_clang function parameters_and_attributes \
   __attribute__ ((__diagnose_if__ (1, msg, "warning")))
 #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
 /* Verify the existence of the function.  */
-#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
-extern rettype function parameters_and_attributes
+#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
+extern rettype_gcc function parameters_and_attributes
 #  else /* Unsupported.  */
-#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+#   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
 _GL_WARN_EXTERN_C int _gl_warn_on_use
 #  endif
 # endif