Parcourir la source

Specific versions of gcc (g++) have a bug that incorrectly warns with
-Wextra as follows: "[class name] has a field [member name] whose type
uses the anonymous namespace", even if the anonymous namespqce in
question is closed in the single translation unit:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29365

AFAICS, the intent was to warn it if the anonymous namespace is used
in a header file (which can easily violate the One Definition Rule as
discussed in the bugzilla), but gcc seemingly did too much to prevent
that.

Unfortunately this bug prohibits us from specifying -Werror, so we
selectively disable this flag by identifying g++ used for build has
this bug.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1371 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya il y a 15 ans
Parent
commit
60e25cf01d
2 fichiers modifiés avec 19 ajouts et 1 suppressions
  1. 15 0
      configure.ac
  2. 4 1
      src/lib/dns/Makefile.am

+ 15 - 0
configure.ac

@@ -25,8 +25,23 @@ AM_PATH_PYTHON([3.1])
 if test "X$GCC" = "Xyes"; then
 CXXFLAGS="$CXXFLAGS -g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
 UNUSED_PARAM_ATTRIBUTE='__attribute__((unused))'
+
+# Certain versions of gcc (g++) have a bug that incorrectly warns about
+# the use of anonymous name spaces even if they're closed in a single
+# translation unit.  For these versions we have to disable -Werror.
+werror_ok=0
+CXXFLAGS_SAVED="$CXXFLAGS"
+CXXFLAGS="$CXXFLAGS -Werror"
+AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
+AC_TRY_COMPILE([namespace { class Foo {}; }
+namespace isc {class Bar {Foo foo_;};} ],,
+	[AC_MSG_RESULT(no)
+	 werror_ok=1],
+	[AC_MSG_RESULT(yes)])
+CXXFLAGS="$CXXFLAGS_SAVED"
 fi
 AC_DEFINE_UNQUOTED(UNUSED_PARAM, $UNUSED_PARAM_ATTRIBUTE, Define to compiler keyword indicating a function argument is intentionally unused)
+AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
 
 # produce PIC unless we disable shared libraries. need this for python bindings.
 if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then

+ 4 - 1
src/lib/dns/Makefile.am

@@ -1,6 +1,9 @@
 SUBDIRS = . tests
 
-AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/ext -Werror
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/ext
+if GCC_WERROR_OK
+AM_CPPFLAGS += -Werror
+endif
 
 CLEANFILES = *.gcno *.gcda
 CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc