changeset 13339:77a366ebede4

Avoid useless warnings from G++.
author Bruno Haible <bruno@clisp.org>
date Thu, 13 May 2010 19:22:39 +0200
parents 43bae0ee08b9
children e8fdc08ffb6b
files ChangeLog build-aux/c++defs.h
diffstat 2 files changed, 35 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-13  Bruno Haible  <bruno@clisp.org>
+
+	Avoid useless warnings from G++.
+	* build-aux/c++defs.h (_GL_CXXALIASWARN_2, _GL_CXXALIASWARN1_2): Don't
+	use _GL_WARN_ON_USE or _GL_WARN_ON_USE_CXX when optimizing.
+	Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>.
+
 2010-05-11  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: tweak preceding change
--- a/build-aux/c++defs.h
+++ b/build-aux/c++defs.h
@@ -221,10 +221,20 @@
    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
 # define _GL_CXXALIASWARN_1(func,namespace) \
    _GL_CXXALIASWARN_2 (func, namespace)
-# define _GL_CXXALIASWARN_2(func,namespace) \
-   _GL_WARN_ON_USE (func, \
-                    "The symbol ::" #func " refers to the system function. " \
-                    "Use " #namespace "::" #func " instead.")
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+   we enable the warning only when not optimizing.  */
+# if !__OPTIMIZE__
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+    _GL_WARN_ON_USE (func, \
+                     "The symbol ::" #func " refers to the system function. " \
+                     "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+     extern __typeof__ (func) func
+# else
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+     _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
 #else
 # define _GL_CXXALIASWARN(func) \
     _GL_EXTERN_C int _gl_cxxalias_dummy
@@ -239,10 +249,20 @@
                         GNULIB_NAMESPACE)
 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
-# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
-   _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
-                        "The symbol ::" #func " refers to the system function. " \
-                        "Use " #namespace "::" #func " instead.")
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+   we enable the warning only when not optimizing.  */
+# if !__OPTIMIZE__
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+                         "The symbol ::" #func " refers to the system function. " \
+                         "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+     extern __typeof__ (func) func
+# else
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+     _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
 #else
 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
     _GL_EXTERN_C int _gl_cxxalias_dummy