public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>, Jeff Law <law@redhat.com>,
	       Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix builtin_mathfn_code ICE on internal fns (PR c++/84444)
Date: Mon, 19 Feb 2018 19:49:00 -0000	[thread overview]
Message-ID: <20180219191115.GS5867@tucnak> (raw)

Hi!

Many years ago Jason has added call to get_callee_fndecl, which does the
right thing for internal functions as well as handles ADDR_EXPR and also
casts and constant function pointers with a usable DECL_INITIAL, so while
to fix this PR I could have added || CALL_EXPR_FN (t)) == NULL_TREE before
the || TREE_CODE (CALL_EXPR_FN (t)) != ADDR_EXPR check, IMHO it is just
better to remove it, get_callee_fndecl will DTRT.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-02-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/84444
	* builtins.c (builtin_mathfn_code): Don't check if CALL_EXPR_FN (t)
	is ADDR_EXPR.

	* g++.dg/cpp1z/launder8.C: New test.

--- gcc/builtins.c.jj	2018-01-18 21:11:57.272207030 +0100
+++ gcc/builtins.c	2018-02-19 14:05:58.887842922 +0100
@@ -7836,8 +7836,7 @@ builtin_mathfn_code (const_tree t)
   const_tree argtype, parmtype;
   const_call_expr_arg_iterator iter;
 
-  if (TREE_CODE (t) != CALL_EXPR
-      || TREE_CODE (CALL_EXPR_FN (t)) != ADDR_EXPR)
+  if (TREE_CODE (t) != CALL_EXPR)
     return END_BUILTINS;
 
   fndecl = get_callee_fndecl (t);
--- gcc/testsuite/g++.dg/cpp1z/launder8.C.jj	2018-02-19 14:13:07.120887805 +0100
+++ gcc/testsuite/g++.dg/cpp1z/launder8.C	2018-02-19 14:12:43.369885316 +0100
@@ -0,0 +1,11 @@
+// PR c++/84444
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A {};
+
+__UINTPTR_TYPE__
+foo (A *p)
+{
+  return (__UINTPTR_TYPE__) __builtin_launder (p);
+}

	Jakub

             reply	other threads:[~2018-02-19 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 19:49 Jakub Jelinek [this message]
2018-02-19 19:33 ` Jeff Law

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=20180219191115.GS5867@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=law@redhat.com \
    --cc=rguenther@suse.de \
    /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).