diff options
author | Jason Merrill <jason@redhat.com> | 2009-07-24 12:02:14 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-07-24 12:02:14 -0400 |
commit | 50ea39ffdbaf4abdfad21637f200292ee5b45b42 (patch) | |
tree | c7c67975df7d7912177f9f97794ed0ea560ea005 /gcc/cp | |
parent | a22fb74c2266c2eb002f9464d13d09b08425fa59 (diff) | |
download | gcc-50ea39ffdbaf4abdfad21637f200292ee5b45b42.tar.gz |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 25 |
2 files changed, 16 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 85178863136..6bb4a57561b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 845fa568529..d396aff12fd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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; |