diff options
author | Jason Merrill <jason@redhat.com> | 2014-12-12 12:52:28 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-12-12 12:52:28 -0500 |
commit | c0b6f54bd34fc824b7dcacf2a57b0b915852389d (patch) | |
tree | df6ec761c866e9b172ded4e4f45948ca749c6c33 /gcc/cp | |
parent | e3501bab810710c32b76884331b1d0d5b58bcc2b (diff) | |
download | gcc-c0b6f54bd34fc824b7dcacf2a57b0b915852389d.zip gcc-c0b6f54bd34fc824b7dcacf2a57b0b915852389d.tar.gz gcc-c0b6f54bd34fc824b7dcacf2a57b0b915852389d.tar.bz2 |
pt.c (do_auto_deduction): In direct-init context, { x } deduces from x.
N3922
* pt.c (do_auto_deduction): In direct-init context, { x } deduces
from x.
From-SVN: r218685
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 16 |
3 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8288481..4fb8a13 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-12-12 Jason Merrill <jason@redhat.com> + N3922 + * pt.c (do_auto_deduction): In direct-init context, { x } deduces + from x. + * cp-tree.h (NAMESPACE_ABI_TAG): New. * name-lookup.c (handle_namespace_attrs): Set it. * class.c (check_tag): Split out from find_abi_tags_r. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index efc2001..5ed9b2c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5546,6 +5546,8 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, of g++.old-deja/g++.mike/p7626.C: a pointer-to-member constant is a CONSTRUCTOR (with a record type). */ if (TREE_CODE (init) == CONSTRUCTOR + /* Don't complain about a capture-init. */ + && !CONSTRUCTOR_IS_DIRECT_INIT (init) && BRACE_ENCLOSED_INITIALIZER_P (init)) /* p7626.C */ { if (SCALAR_TYPE_P (type)) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d8a9c5b..8a663d9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -22117,7 +22117,21 @@ do_auto_deduction (tree type, tree init, tree auto_node) initializer is a braced-init-list (8.5.4), with std::initializer_list<U>. */ if (BRACE_ENCLOSED_INITIALIZER_P (init)) - type = listify_autos (type, auto_node); + { + if (!DIRECT_LIST_INIT_P (init)) + type = listify_autos (type, auto_node); + else if (CONSTRUCTOR_NELTS (init) == 1) + init = CONSTRUCTOR_ELT (init, 0)->value; + else + { + if (permerror (input_location, "direct-list-initialization of " + "%<auto%> requires exactly one element")) + inform (input_location, + "for deduction to %<std::initializer_list%>, use copy-" + "list-initialization (i.e. add %<=%> before the %<{%>)"); + type = listify_autos (type, auto_node); + } + } init = resolve_nondeduced_context (init); |