call.c (reference_binding): Allow direct binding to an array rvalue.
authorJason Merrill <jason@redhat.com>
Mon, 28 Mar 2011 16:14:12 +0000 (12:14 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 28 Mar 2011 16:14:12 +0000 (12:14 -0400)
* call.c (reference_binding): Allow direct binding to an array
rvalue.

From-SVN: r171613

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C [new file with mode: 0644]

index 062468b38fe318047180cf606273c45ca1d9df0a..15d8a9793871aa7f428ff6ef65bc355271574f13 100644 (file)
@@ -1,5 +1,8 @@
 2011-03-28  Jason Merrill  <jason@redhat.com>
 
+       * 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.
index 93383c69f07cc6cc0b9f5a6657755466eec3ed97..9a9ac760d3f48a68d2cfbc48af4d9bc82cd93f44 100644 (file)
@@ -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]
 
index 248bfccb1dc3c70a21bf7b677b60de23607de83f..2424c15f2fd4ca411f5c165e9b25c9043fd46896 100644 (file)
@@ -1,5 +1,7 @@
 2011-03-28  Jason Merrill  <jason@redhat.com>
 
+       * 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 (file)
index 0000000..25113d7
--- /dev/null
@@ -0,0 +1,5 @@
+// { dg-options -std=c++0x }
+
+typedef int IRT[2];
+
+const IRT& ir = IRT{1,2};