From 159177a1542d7bc9ca5110aa1dcc7dde9a799024 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 28 Mar 2011 12:14:12 -0400 Subject: [PATCH] call.c (reference_binding): Allow direct binding to an array rvalue. * call.c (reference_binding): Allow direct binding to an array rvalue. From-SVN: r171613 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/call.c | 4 +++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 062468b38fe..15d8a979387 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-03-28 Jason Merrill + * call.c (reference_binding): Allow direct binding to an array + rvalue. + Core 898 * parser.c (cp_parser_compound_statement): Add function_body parm. Complain about non-body compound-stmt in constexpr fn. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 93383c69f07..9a9ac760d3f 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1429,7 +1429,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) || (((CP_TYPE_CONST_NON_VOLATILE_P (to) && !(flags & LOOKUP_NO_TEMP_BIND)) || TYPE_REF_IS_RVALUE (rto)) - && (CLASS_TYPE_P (from) || (expr && lvalue_p (expr)))))) + && (CLASS_TYPE_P (from) + || TREE_CODE (from) == ARRAY_TYPE + || (expr && lvalue_p (expr)))))) { /* [dcl.init.ref] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 248bfccb1dc..2424c15f2fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-03-28 Jason Merrill + * g++.dg/cpp0x/initlist-array1.C: New. + * g++.dg/cpp0x/constexpr-compound.C: New. * g++.dg/cpp0x/constexpr-using.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C new file mode 100644 index 00000000000..25113d770b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +typedef int IRT[2]; + +const IRT& ir = IRT{1,2};