This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix ICE with C++17 decomposition of invisiref parameter (PR c++/79205)


Hi!

The following testcase ICEd because genericization handled
an is_invisiref_parm PARM_DECL in DECL_INITIAL of the decomposition
artificial variable twice.  Fixed by making sure we don't walk
the INDIRECT_REFs added by convert_from_reference for is_invisiref_parm
PARM_DECLs.

Bootstrapped/regtested on x86_64-linux and i686-linux, approved by Jason in
the PR, committed to trunk.

2017-01-24  Jakub Jelinek  <jakub@redhat.com>

	PR c++/79205
	* cp-gimplify.c (cp_genericize_r): Add result of
	convert_from_reference on invisiref parm to p_set.

	* g++.dg/cpp1z/decomp22.C: New test.
	* g++.dg/cpp1z/decomp23.C: New test.

--- gcc/cp/cp-gimplify.c.jj	2017-01-21 02:26:06.000000000 +0100
+++ gcc/cp/cp-gimplify.c	2017-01-24 10:44:58.395850677 +0100
@@ -1107,6 +1107,7 @@ cp_genericize_r (tree *stmt_p, int *walk
   if (wtd->handle_invisiref_parm_p && is_invisiref_parm (stmt))
     {
       *stmt_p = convert_from_reference (stmt);
+      p_set->add (*stmt_p);
       *walk_subtrees = 0;
       return NULL;
     }
--- gcc/testsuite/g++.dg/cpp1z/decomp22.C.jj	2017-01-24 10:45:51.311156064 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp22.C	2017-01-24 10:58:16.241237946 +0100
@@ -0,0 +1,21 @@
+// PR c++/79205
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template <unsigned long, typename...> struct B;
+template <unsigned long I, typename H> struct B<I, H> { int b; };
+template <typename... E> struct C { B<0, E...> c; C (C &) = default; C (C &&); };
+template <typename> struct tuple_size;
+template <> struct tuple_size<C<int>> { static constexpr int value = 1; };
+template <int, typename> struct tuple_element;
+template <typename H, typename... T>
+struct tuple_element<0, C<H, T...>> { typedef int type; };
+template <int, typename... E>
+int &&get (C<E...> &&);
+
+int
+foo (C<int> t)
+{
+  auto[x0] = t;	// { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+  return x0;
+}
--- gcc/testsuite/g++.dg/cpp1z/decomp23.C.jj	2017-01-24 10:50:47.623266415 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp23.C	2017-01-24 10:58:25.816108949 +0100
@@ -0,0 +1,12 @@
+// PR c++/79205
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+#include <tuple>
+
+int
+foo (std::tuple<int> t)
+{
+  auto [x0] = t;	// { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+  return x0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]