+2017-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/79372
+ * decl.c (cp_finish_decomp): On error set decl type to error_mark_node.
+ * pt.c (tsubst_expr): Don't call tsubst_decomp_names on decompositions
+ with error_mark_node type.
+
2017-02-03 Jason Merrill <jason@redhat.com>
PR c++/78689 - ICE on constructor with label
}
first = DECL_CHAIN (first);
}
+ TREE_TYPE (decl) = error_mark_node;
if (DECL_P (decl) && DECL_NAMESPACE_SCOPE_P (decl))
SET_DECL_ASSEMBLER_NAME (decl, get_identifier ("<decomp>"));
return;
const_init = (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P
(pattern_decl));
cp_finish_decl (decl, init, const_init, NULL_TREE, 0);
- if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl))
+ if (VAR_P (decl)
+ && DECL_DECOMPOSITION_P (decl)
+ && TREE_TYPE (pattern_decl) != error_mark_node)
{
unsigned int cnt;
tree first;
2017-02-06 Jakub Jelinek <jakub@redhat.com>
+ PR c++/79372
+ * g++.dg/cpp1z/decomp25.C: New test.
+
PR tree-optimization/79284
* gcc.c-torture/compile/pr79284.c: New test.
--- /dev/null
+// PR c++/79372
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template <typename T>
+struct S
+{
+ enum E { A };
+ void f () { auto [x] = 0; x++; } // { dg-error "cannot decompose non-array non-class type" }
+ // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+ void g (T t) { auto [y] = t; y++; } // { dg-error "cannot decompose non-array non-class type" }
+}; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+
+int
+main ()
+{
+ S <int> s;
+ s.f ();
+ s.g (5);
+}