This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] config: Check for and use gcc -Wnull-dereference.


-Wnull-dereference is new in GCC6

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 ChangeLog        |  4 ++++
 config/ChangeLog |  5 +++++
 config/eu.am     |  7 +++++++
 configure.ac     | 10 ++++++++++
 4 files changed, 26 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d206a8e..0a8166b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-13  Mark Wielaard  <mjw@redhat.com>
+
+	* configure.ac: Add check for whether gcc accepts -Wnull-dereference.
+
 2016-02-98  Mark Wielaard  <mjw@redhat.com>
 
 	* configure.ac: Add checks for sane -Wlogical-op and whether gcc
diff --git a/config/ChangeLog b/config/ChangeLog
index 8523cb3..494778a 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-13  Mark Wielaard  <mjw@redhat.com>
+
+	* eu.am: Check HAVE_NULL_DEREFERENCE_WARNING.
+	(AM_CFLAGS): Add NULL_DEREFERENCE_WARNING.
+
 2016-02-09  Mark Wielaard  <mjw@redhat.com>
 
 	* eu.am: Check SANE_LOGICAL_OP_WARNING and
diff --git a/config/eu.am b/config/eu.am
index c4e9279..4998771 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -55,9 +55,16 @@ else
 DUPLICATED_COND_WARNING=
 endif
 
+if HAVE_NULL_DEREFERENCE_WARNING
+NULL_DEREFERENCE_WARNING=-Wnull-dereference
+else
+NULL_DEREFERENCE_WARNING=
+endif
+
 AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
 	    -Wold-style-definition -Wstrict-prototypes \
 	    $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
+	    $(NULL_DEREFERENCE_WARNING) \
 	    $(if $($(*F)_no_Werror),,-Werror) \
 	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
 	    $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
diff --git a/configure.ac b/configure.ac
index d447db7..df58b5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -313,6 +313,16 @@ CFLAGS="$old_CFLAGS"])
 AM_CONDITIONAL(HAVE_DUPLICATED_COND_WARNING,
 	       [test "x$ac_cv_duplicated_cond" != "xno"])
 
+# -Wnull-dereference was added by GCC6
+AC_CACHE_CHECK([whether gcc accepts -Wnull-dereference], ac_cv_null_dereference, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wnull-dereference"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+		  ac_cv_null_dereference=yes, ac_cv_null_dereference=no)
+CFLAGS="$old_CFLAGS"])
+AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING,
+	       [test "x$ac_cv_null_dereference" != "xno"])
+
 dnl Check if we have argp available from our libc
 AC_LINK_IFELSE(
 	[AC_LANG_PROGRAM(
-- 
2.5.0

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]