public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ICE with __builtin_launder (PR c++/84445)
@ 2018-02-19 19:08 Jakub Jelinek
  2018-02-20  3:13 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-02-19 19:08 UTC (permalink / raw)
  To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches

Hi!

For internal functions, we use the whole u.bits of the CALL_EXPR
for the internal function number (in this case IFN_LAUNDER), so using
the lang flags on it doesn't work.  In a couple of other places
I've checked that test or set lang flags on CALL_EXPR I saw internal fns
special cased early, but admittedly haven't checked everything.

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

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

	PR c++/84445
	* class.c (fixed_type_or_null) <case CALL_EXPR>: Only test
	TREE_HAS_CONSTRUCTOR if instance is not an internal function call.

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

--- gcc/cp/class.c.jj	2018-02-16 19:39:08.184061984 +0100
+++ gcc/cp/class.c	2018-02-19 13:34:33.726813207 +0100
@@ -7128,7 +7128,8 @@ fixed_type_or_null (tree instance, int *
 
     case CALL_EXPR:
       /* This is a call to a constructor, hence it's never zero.  */
-      if (TREE_HAS_CONSTRUCTOR (instance))
+      if (CALL_EXPR_FN (instance)
+	  && TREE_HAS_CONSTRUCTOR (instance))
 	{
 	  if (nonnull)
 	    *nonnull = 1;
--- gcc/testsuite/g++.dg/cpp1z/launder7.C.jj	2018-02-19 13:50:05.954797679 +0100
+++ gcc/testsuite/g++.dg/cpp1z/launder7.C	2018-02-19 13:47:26.603792932 +0100
@@ -0,0 +1,10 @@
+// PR c++/84445
+// { dg-do compile }
+
+struct A { virtual void foo (); };
+
+void
+bar (A *p)
+{
+  __builtin_launder (p)->foo ();
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Fix ICE with __builtin_launder (PR c++/84445)
  2018-02-19 19:08 [C++ PATCH] Fix ICE with __builtin_launder (PR c++/84445) Jakub Jelinek
@ 2018-02-20  3:13 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-02-20  3:13 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Nathan Sidwell, gcc-patches List

OK.

On Mon, Feb 19, 2018 at 2:08 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> For internal functions, we use the whole u.bits of the CALL_EXPR
> for the internal function number (in this case IFN_LAUNDER), so using
> the lang flags on it doesn't work.  In a couple of other places
> I've checked that test or set lang flags on CALL_EXPR I saw internal fns
> special cased early, but admittedly haven't checked everything.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-02-19  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/84445
>         * class.c (fixed_type_or_null) <case CALL_EXPR>: Only test
>         TREE_HAS_CONSTRUCTOR if instance is not an internal function call.
>
>         * g++.dg/cpp1z/launder7.C: New test.
>
> --- gcc/cp/class.c.jj   2018-02-16 19:39:08.184061984 +0100
> +++ gcc/cp/class.c      2018-02-19 13:34:33.726813207 +0100
> @@ -7128,7 +7128,8 @@ fixed_type_or_null (tree instance, int *
>
>      case CALL_EXPR:
>        /* This is a call to a constructor, hence it's never zero.  */
> -      if (TREE_HAS_CONSTRUCTOR (instance))
> +      if (CALL_EXPR_FN (instance)
> +         && TREE_HAS_CONSTRUCTOR (instance))
>         {
>           if (nonnull)
>             *nonnull = 1;
> --- gcc/testsuite/g++.dg/cpp1z/launder7.C.jj    2018-02-19 13:50:05.954797679 +0100
> +++ gcc/testsuite/g++.dg/cpp1z/launder7.C       2018-02-19 13:47:26.603792932 +0100
> @@ -0,0 +1,10 @@
> +// PR c++/84445
> +// { dg-do compile }
> +
> +struct A { virtual void foo (); };
> +
> +void
> +bar (A *p)
> +{
> +  __builtin_launder (p)->foo ();
> +}
>
>         Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-20  3:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 19:08 [C++ PATCH] Fix ICE with __builtin_launder (PR c++/84445) Jakub Jelinek
2018-02-20  3:13 ` Jason Merrill

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).