summaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-12 17:52:28 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-12 17:52:28 +0000
commitc93d516fb71f4f17ab296d273e1e6582a45ed8bb (patch)
treedf6ec761c866e9b172ded4e4f45948ca749c6c33 /gcc/cp/pt.c
parent111eaa956cf338711a3ccaa2dd8efd39e211abbe (diff)
downloadgcc-c93d516fb71f4f17ab296d273e1e6582a45ed8bb.tar.gz
N3922
* pt.c (do_auto_deduction): In direct-init context, { x } deduces from x. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218685 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d8a9c5b1b32..8a663d98c47 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);