Commit a4dfaae1 by Jason Merrill Committed by Jason Merrill

PR c++/80084 - wrong C++17 decomposition by reference of parameter.

	* decl.c (cp_finish_decomp): Don't pull out the DECL_INITIAL of a
	reference decomposition.

From-SVN: r246273
parent c8816908
2017-03-19 Jason Merrill <jason@redhat.com>
PR c++/80084 - wrong C++17 decomposition by reference of parameter.
* decl.c (cp_finish_decomp): Don't pull out the DECL_INITIAL of a
reference decomposition.
PR c++/80077 - error with constexpr and -fno-elide-constructors.
* constexpr.c (cxx_eval_call_expression): Set ctx->call while
expanding trivial constructor.
......
......@@ -7439,9 +7439,6 @@ cp_finish_decomp (tree decl, tree first, unsigned int count)
if (TREE_CODE (type) == REFERENCE_TYPE)
{
/* If e is a constant reference, use the referent directly. */
if (DECL_INITIAL (decl))
dexp = DECL_INITIAL (decl);
dexp = convert_from_reference (dexp);
type = TREE_TYPE (type);
}
......
// PR c++/80084
// { dg-options -std=c++1z }
// { dg-do run }
struct A
{
A() { }
A(const A&) { }
};
struct B
{
A a;
};
void f(B b)
{
auto& [a] = b;
if (&a != &b.a)
__builtin_abort();
}
int main()
{
f(B());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment