This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, Nathan Sidwell <nathan at acm dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Mar 2018 10:52:02 +0200
- Subject: [C++ PATCH] Fix ICE in cp_build_reference_type (PR c++/85076)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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