commit e9f73b2b5a67a425ae52755a6f9bebe16fc2398d
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 3 13:16:14 2013 -0500
PR c++/55856
* semantics.c (build_data_member_initialization): Handle DECL_EXPR.
@@ -5848,15 +5848,19 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
member = TREE_OPERAND (t, 0);
init = unshare_expr (TREE_OPERAND (t, 1));
}
- else
+ else if (TREE_CODE (t) == CALL_EXPR)
{
- gcc_assert (TREE_CODE (t) == CALL_EXPR);
member = CALL_EXPR_ARG (t, 0);
/* We don't use build_cplus_new here because it complains about
abstract bases. Leaving the call unwrapped means that it has the
wrong type, but cxx_eval_constant_expression doesn't care. */
init = unshare_expr (t);
}
+ else if (TREE_CODE (t) == DECL_EXPR)
+ /* Declaring a temporary, don't add it to the CONSTRUCTOR. */
+ return true;
+ else
+ gcc_unreachable ();
if (TREE_CODE (member) == INDIRECT_REF)
member = TREE_OPERAND (member, 0);
if (TREE_CODE (member) == NOP_EXPR)
new file mode 100644
@@ -0,0 +1,16 @@
+// PR c++/55856
+// { dg-options -std=c++11 }
+
+struct A
+{
+ A(const char *);
+};
+
+template <class T>
+struct B
+{
+ T t;
+ template <class U> constexpr B(U&& u): t(u) { };
+};
+
+B<A&&> b("");