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
This commit is contained in:
Jason Merrill 2009-07-24 12:02:14 -04:00 committed by Jason Merrill
parent a22fb74c22
commit 50ea39ffdb
4 changed files with 35 additions and 15 deletions

View File

@ -1,3 +1,9 @@
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>
* mangle.c (mangle_type_string_for_rtti): Rename to be clearer.

View File

@ -6493,6 +6493,14 @@ compare_ics (conversion *ics1, conversion *ics2)
ref_conv1 = maybe_handle_ref_bind (&ics1);
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]
When comparing the basic forms of implicit conversion sequences (as
@ -6543,26 +6551,13 @@ compare_ics (conversion *ics1, conversion *ics2)
conversion *t1;
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)
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)
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)
return 0;

View File

@ -1,3 +1,7 @@
2009-07-24 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist23.C: New.
2009-07-24 Janus Weil <janus@gcc.gnu.org>
PR fortran/40822

View File

@ -0,0 +1,15 @@
// { 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 = { };
}