public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] config: Check for and use gcc -Wnull-dereference.
Date: Sat, 13 Feb 2016 19:11:18 +0100	[thread overview]
Message-ID: <1455387078-29653-1-git-send-email-mjw@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2451 bytes --]

-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

             reply	other threads:[~2016-02-13 18:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-13 18:11 Mark Wielaard [this message]
2016-02-22 11:11 Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455387078-29653-1-git-send-email-mjw@redhat.com \
    --to=mjw@redhat.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).