tree
lookup_decomp_type (tree v)
{
- return *decomp_type_table->get (v);
+ if (tree *slot = decomp_type_table->get (v))
+ return *slot;
+ return NULL_TREE;
}
/* Mangle a decomposition declaration if needed. Arguments like
access expression). */
if (DECL_DECOMPOSITION_P (expr))
{
+ if (ptds.saved)
+ {
+ gcc_checking_assert (DECL_HAS_VALUE_EXPR_P (expr));
+ /* DECL_HAS_VALUE_EXPR_P is always set if
+ processing_template_decl. If lookup_decomp_type
+ returns non-NULL, it is the tuple case. */
+ if (tree ret = lookup_decomp_type (expr))
+ return ret;
+ }
if (DECL_HAS_VALUE_EXPR_P (expr))
/* Expr is an array or struct subobject proxy, handle
bit-fields properly. */
--- /dev/null
+// PR c++/92687
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+namespace std {
+ template<typename T> struct tuple_size;
+ template<int, typename> struct tuple_element;
+}
+
+struct A {
+ int i;
+ template <int I> int& get() { return i; }
+};
+
+template<> struct std::tuple_size<A> { static const int value = 2; };
+template<int I> struct std::tuple_element<I,A> { using type = int; };
+
+template<typename T>
+struct is_reference {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_reference<T&>
+{
+ static const bool value = true;
+};
+
+template<typename T>
+struct is_reference<T&&>
+{
+ static const bool value = true;
+};
+
+template<int N>
+void
+foo ()
+{
+ auto [x, y] = A {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (!is_reference<decltype (x)>::value, "");
+}
+
+void
+bar ()
+{
+ auto [x, y] = A {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (!is_reference<decltype (x)>::value, "");
+}
+
+template<typename T>
+void
+baz ()
+{
+ auto [x, y] = T {}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (!is_reference<decltype (x)>::value, "");
+}
+
+void
+qux ()
+{
+ foo<0> ();
+ baz<A> ();
+}