PR c++/78931
* decl.c (cp_finish_decomp): Remove probe variable, if tt is
REFERENCE_REF_P, set tt to its operand.
* g++.dg/cpp1z/decomp19.C: New test.
From-SVN: r244113
2017-01-05 Jakub Jelinek <jakub@redhat.com>
+ PR c++/78931
+ * decl.c (cp_finish_decomp): Remove probe variable, if tt is
+ REFERENCE_REF_P, set tt to its operand.
+
PR c++/78890
* class.c (check_field_decls): Diagnose REFERENCE_TYPE fields in
unions even for C++11 and later.
else
{
tree tt = finish_non_static_data_member (field, t, NULL_TREE);
- tree probe = tt;
- if (REFERENCE_REF_P (probe))
- probe = TREE_OPERAND (probe, 0);
- TREE_TYPE (v[i]) = TREE_TYPE (probe);
+ if (REFERENCE_REF_P (tt))
+ tt = TREE_OPERAND (tt, 0);
+ TREE_TYPE (v[i]) = TREE_TYPE (tt);
layout_decl (v[i], 0);
SET_DECL_VALUE_EXPR (v[i], tt);
DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
2017-01-05 Jakub Jelinek <jakub@redhat.com>
+ PR c++/78931
+ * g++.dg/cpp1z/decomp19.C: New test.
+
PR c++/78890
* g++.dg/init/ref14.C: Expect error even in C++11 and later.
* g++.dg/init/union1.C: Likewise.
--- /dev/null
+// PR c++/78931
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+int
+main ()
+{
+ int x = 99;
+ struct S { int &x; };
+ S s{x};
+ auto [p] = s; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ return p - 99;
+}