public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076)
@ 2018-03-27  8:55 Jakub Jelinek
  2018-03-27 19:55 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-27  8:55 UTC (permalink / raw)
  To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches

Hi!

Both build_{reference,pointer}_type start with if (to_type ==
error_mark_node) return error_mark_node;

cp_build_reference_type uses build_reference_type, so in many cases it will
just return error_mark_node if it is passed, but if rval is true, it will
assume build_reference_type returned some REFERENCE_TYPE instead.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2018-03-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/85076
	* tree.c (cp_build_reference_type): If to_type is error_mark_node,
	return it right away.

	* g++.dg/cpp1y/pr85076.C: New test.

--- gcc/cp/tree.c.jj	2018-03-21 21:18:31.738351376 +0100
+++ gcc/cp/tree.c	2018-03-26 11:22:47.067967708 +0200
@@ -1078,6 +1078,9 @@ cp_build_reference_type (tree to_type, b
 {
   tree lvalue_ref, t;
 
+  if (to_type == error_mark_node)
+    return error_mark_node;
+
   if (TREE_CODE (to_type) == REFERENCE_TYPE)
     {
       rval = rval && TYPE_REF_IS_RVALUE (to_type);
--- gcc/testsuite/g++.dg/cpp1y/pr85076.C.jj	2018-03-26 11:26:55.725047985 +0200
+++ gcc/testsuite/g++.dg/cpp1y/pr85076.C	2018-03-26 11:26:41.807043494 +0200
@@ -0,0 +1,6 @@
+// PR c++/85076
+// { dg-do compile { target c++14 } }
+
+template<typename> struct A*;	// { dg-error "expected unqualified-id before" }
+
+auto a = [](A<auto>) {};	// { dg-error "is not a template|has incomplete type" }

	Jakub

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

* Re: [C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076)
  2018-03-27  8:55 [C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076) Jakub Jelinek
@ 2018-03-27 19:55 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-03-27 19:55 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Nathan Sidwell, gcc-patches List

OK.

On Tue, Mar 27, 2018 at 4:52 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Both build_{reference,pointer}_type start with if (to_type ==
> error_mark_node) return error_mark_node;
>
> cp_build_reference_type uses build_reference_type, so in many cases it will
> just return error_mark_node if it is passed, but if rval is true, it will
> assume build_reference_type returned some REFERENCE_TYPE instead.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2018-03-27  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/85076
>         * tree.c (cp_build_reference_type): If to_type is error_mark_node,
>         return it right away.
>
>         * g++.dg/cpp1y/pr85076.C: New test.
>
> --- gcc/cp/tree.c.jj    2018-03-21 21:18:31.738351376 +0100
> +++ gcc/cp/tree.c       2018-03-26 11:22:47.067967708 +0200
> @@ -1078,6 +1078,9 @@ cp_build_reference_type (tree to_type, b
>  {
>    tree lvalue_ref, t;
>
> +  if (to_type == error_mark_node)
> +    return error_mark_node;
> +
>    if (TREE_CODE (to_type) == REFERENCE_TYPE)
>      {
>        rval = rval && TYPE_REF_IS_RVALUE (to_type);
> --- gcc/testsuite/g++.dg/cpp1y/pr85076.C.jj     2018-03-26 11:26:55.725047985 +0200
> +++ gcc/testsuite/g++.dg/cpp1y/pr85076.C        2018-03-26 11:26:41.807043494 +0200
> @@ -0,0 +1,6 @@
> +// PR c++/85076
> +// { dg-do compile { target c++14 } }
> +
> +template<typename> struct A*;  // { dg-error "expected unqualified-id before" }
> +
> +auto a = [](A<auto>) {};       // { dg-error "is not a template|has incomplete type" }
>
>         Jakub

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

end of thread, other threads:[~2018-03-27 19:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27  8:55 [C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076) Jakub Jelinek
2018-03-27 19:55 ` 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).