Bug 529441: Build with -Werror=return-type (where available) so that not returning a value from a non-void function results in a build error instead of a warning. r=luser
authorChris Jones <jones.chris.g@gmail.com>
Mon, 04 Jan 2010 12:13:58 -0600
changeset 36830 a9addb7dc548e3a7593cbf4ecec872762619ee6b
parent 36829 01f4b785c8861e1aa5963f3203f4e7dd631d6267
child 36831 3975716a6eb4c61d535a340b4656cce1e7ceb3d6
push idunknown
push userunknown
push dateunknown
reviewersluser
bugs529441
milestone1.9.3a1pre
Bug 529441: Build with -Werror=return-type (where available) so that not returning a value from a non-void function results in a build error instead of a warning. r=luser
configure.in
--- a/configure.in
+++ b/configure.in
@@ -1528,16 +1528,34 @@ if test "$GNU_CXX"; then
                            ac_has_wno_variadic_macros="no")
             CXXFLAGS="$_SAVE_CXXFLAGS"
             AC_LANG_RESTORE
         ])
     if test "$ac_has_wno_variadic_macros" = "yes"; then
         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} ${_COMPILER_PREFIX}-Wno-variadic-macros"
     fi
 
+    AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
+                   ac_has_werror_return_type,
+        [
+            AC_LANG_SAVE
+            AC_LANG_CPLUSPLUS
+            _SAVE_CXXFLAGS="$CXXFLAGS"
+            CXXFLAGS="$CXXFLAGS -Werror=return-type"
+            AC_TRY_COMPILE([],
+                           [return(0);],
+                           ac_has_werror_return_type="yes",
+                           ac_has_werror_return_type="no")
+            CXXFLAGS="$_SAVE_CXXFLAGS"
+            AC_LANG_RESTORE
+        ])
+    if test "$ac_has_werror_return_type" = "yes"; then
+        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
+    fi
+
 else
     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
 fi
 
 dnl gcc can come with its own linker so it is better to use the pass-thru calls
 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
 dnl normal behavior.