public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: C/C++ PATCH to implement -Wpointer-compare warning (PR c++/64767)
Date: Wed, 21 Sep 2016 19:55:00 -0000	[thread overview]
Message-ID: <CADzB+2nx2urLeSBDzy7LZzRm+cw5QsR9JHC72dSwORtF17-usg@mail.gmail.com> (raw)
In-Reply-To: <CADzB+2nOk_Ymt4HUxO8Q-8z3arczdjusgi9kg26pJ6Gx0kxkMw@mail.gmail.com>

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

On Mon, Sep 19, 2016 at 2:49 PM, Jason Merrill <jason@redhat.com> wrote:
> I suppose that an INTEGER_CST of character type is necessarily a
> character constant, so adding a check for !char_type_p ought to do the
> trick.

Indeed it does.  I'm checking this in:

[-- Attachment #2: char903.diff --]
[-- Type: text/x-patch, Size: 918 bytes --]

commit d2f237ef0f63b3ee3da79bcbfad08fedb325d554
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Sep 21 10:58:39 2016 -0400

            Core 903
            * call.c (null_ptr_cst_p): Check char_type_p.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 393aab9..2804bd8 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -527,6 +527,7 @@ null_ptr_cst_p (tree t)
     {
       /* Core issue 903 says only literal 0 is a null pointer constant.  */
       if (TREE_CODE (type) == INTEGER_TYPE
+	  && !char_type_p (type)
 	  && TREE_CODE (t) == INTEGER_CST
 	  && integer_zerop (t)
 	  && !TREE_OVERFLOW (t))
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr36.C b/gcc/testsuite/g++.dg/cpp0x/nullptr36.C
new file mode 100644
index 0000000..5f43881
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr36.C
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+
+void *p = '\0';			// { dg-error "invalid conversion" }

  reply	other threads:[~2016-09-21 19:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-10 15:06 Marek Polacek
2016-09-10 15:13 ` Jakub Jelinek
2016-09-10 15:48   ` Marek Polacek
2016-09-14  5:56 ` Jason Merrill
2016-09-15 12:31   ` Marek Polacek
2016-09-19 19:51     ` Jason Merrill
2016-09-21 19:55       ` Jason Merrill [this message]
2016-09-23 13:29         ` Marek Polacek
2016-09-23 14:37           ` Jason Merrill
2016-09-30 16:52             ` Marek Polacek
2016-09-30 17:22               ` Martin Sebor
2016-09-30 19:52                 ` Martin Sebor
2016-09-30 20:02                   ` Marek Polacek
2016-09-30 22:16                     ` Martin Sebor
2016-09-30 22:16               ` Jason Merrill
2016-10-01 14:41                 ` Marek Polacek
2016-10-02 18:43                   ` Jason Merrill
2017-01-04  6:56                     ` Eric Gallager

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=CADzB+2nx2urLeSBDzy7LZzRm+cw5QsR9JHC72dSwORtF17-usg@mail.gmail.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=polacek@redhat.com \
    /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).