Commit 50ea39ff by Jason Merrill Committed by Jason Merrill

Core issue 702

	Core issue 702
	* call.c (compare_ics): Give list-initialization of std::init_list
	priority over conversion to scalar, too.

From-SVN: r150059
parent a22fb74c
2009-07-24 Jason Merrill <jason@redhat.com>
Core issue 702
* call.c (compare_ics): Give list-initialization of std::init_list
priority over conversion to scalar, too.
2009-07-22 Jason Merrill <jason@redhat.com> 2009-07-22 Jason Merrill <jason@redhat.com>
* mangle.c (mangle_type_string_for_rtti): Rename to be clearer. * mangle.c (mangle_type_string_for_rtti): Rename to be clearer.
......
...@@ -6493,6 +6493,14 @@ compare_ics (conversion *ics1, conversion *ics2) ...@@ -6493,6 +6493,14 @@ compare_ics (conversion *ics1, conversion *ics2)
ref_conv1 = maybe_handle_ref_bind (&ics1); ref_conv1 = maybe_handle_ref_bind (&ics1);
ref_conv2 = maybe_handle_ref_bind (&ics2); ref_conv2 = maybe_handle_ref_bind (&ics2);
/* List-initialization sequence L1 is a better conversion sequence than
list-initialization sequence L2 if L1 converts to
std::initializer_list<X> for some X and L2 does not. */
if (ics1->kind == ck_list && ics2->kind != ck_list)
return 1;
if (ics2->kind == ck_list && ics1->kind != ck_list)
return -1;
/* [over.ics.rank] /* [over.ics.rank]
When comparing the basic forms of implicit conversion sequences (as When comparing the basic forms of implicit conversion sequences (as
...@@ -6543,26 +6551,13 @@ compare_ics (conversion *ics1, conversion *ics2) ...@@ -6543,26 +6551,13 @@ compare_ics (conversion *ics1, conversion *ics2)
conversion *t1; conversion *t1;
conversion *t2; conversion *t2;
for (t1 = ics1; t1->kind != ck_user && t1->kind != ck_list; t1 = t1->u.next) for (t1 = ics1; t1->kind != ck_user; t1 = t1->u.next)
if (t1->kind == ck_ambig || t1->kind == ck_aggr) if (t1->kind == ck_ambig || t1->kind == ck_aggr)
return 0; return 0;
for (t2 = ics2; t2->kind != ck_user && t2->kind != ck_list; t2 = t2->u.next) for (t2 = ics2; t2->kind != ck_user; t2 = t2->u.next)
if (t2->kind == ck_ambig || t2->kind == ck_aggr) if (t2->kind == ck_ambig || t2->kind == ck_aggr)
return 0; return 0;
/* Conversion to std::initializer_list is better than other
user-defined conversions. */
if (t1->kind == ck_list
|| t2->kind == ck_list)
{
if (t2->kind != ck_list)
return 1;
else if (t1->kind != ck_list)
return -1;
else
return 0;
}
if (t1->cand->fn != t2->cand->fn) if (t1->cand->fn != t2->cand->fn)
return 0; return 0;
......
2009-07-24 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist23.C: New.
2009-07-24 Janus Weil <janus@gcc.gnu.org> 2009-07-24 Janus Weil <janus@gcc.gnu.org>
PR fortran/40822 PR fortran/40822
......
// { dg-options "-std=c++0x" }
#include <initializer_list>
struct A
{
A& operator=(int i);
A& operator=(std::initializer_list<int> l) { return *this; }
};
int main()
{
A a;
a = { };
}
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