aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-07-22 03:32:30 +0000
committerJason Merrill <jason@redhat.com>2009-07-22 03:32:30 +0000
commit660330cdcd2db347527a034065793b1c9f059b26 (patch)
tree76a85593349333fc713e0b713267805df1ca478c /gcc/cp/call.c
parent66e8909fd72f3292f09b45bc662b974cb0f5b10d (diff)
Core issue 934
* call.c (reference_binding): Implement binding to { }. (initialize_reference): Binding temporary to non-const && is fine. * decl.c (grok_reference_init): Remove error for CONSTRUCTOR. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@149873 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f4b5b02bb45..845fa568529 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1221,7 +1221,21 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
lvalue_p = clk_ordinary;
from = TREE_TYPE (from);
}
- else if (expr)
+
+ if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr))
+ {
+ maybe_warn_cpp0x ("extended initializer lists");
+ conv = implicit_conversion (to, from, expr, c_cast_p,
+ flags);
+ if (!CLASS_TYPE_P (to)
+ && CONSTRUCTOR_NELTS (expr) == 1)
+ {
+ expr = CONSTRUCTOR_ELT (expr, 0)->value;
+ from = TREE_TYPE (expr);
+ }
+ }
+
+ if (lvalue_p == clk_none && expr)
lvalue_p = real_lvalue_p (expr);
tfrom = from;
@@ -1363,8 +1377,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
if (!(flags & LOOKUP_COPY_PARM))
flags |= LOOKUP_ONLYCONVERTING;
- conv = implicit_conversion (to, from, expr, c_cast_p,
- flags);
+ if (!conv)
+ conv = implicit_conversion (to, from, expr, c_cast_p,
+ flags);
if (!conv)
return NULL;
@@ -7541,6 +7556,7 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
if (!conv || conv->bad_p)
{
if (!(TYPE_QUALS (TREE_TYPE (type)) & TYPE_QUAL_CONST)
+ && !TYPE_REF_IS_RVALUE (type)
&& !real_lvalue_p (expr))
error ("invalid initialization of non-const reference of "
"type %qT from a temporary of type %qT",