aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-12-19 15:10:49 -0500
committerJason Merrill <jason@gcc.gnu.org>2011-12-19 15:10:49 -0500
commit11c71a22d90023ec27f04b80e92838af8af692a2 (patch)
tree1f29fff9643d552d01255418d102f7c4d9dc4eeb /gcc/cp/call.c
parent00ef7059049de2761ed8c9db8839ce3566d09cb7 (diff)
downloadgcc-11c71a22d90023ec27f04b80e92838af8af692a2.zip
gcc-11c71a22d90023ec27f04b80e92838af8af692a2.tar.gz
gcc-11c71a22d90023ec27f04b80e92838af8af692a2.tar.bz2
re PR c++/51553 (brace initialization and conversion operators)
PR c++/51553 * cp-tree.h (LOOKUP_LIST_INIT_CTOR): Rename from LOOKUP_NO_COPY_CTOR_CONVERSION. (add_list_candidates): Set it earlier. (add_candidates): Don't check explicit on ctors when it's set. (add_function_candidate): Check it even when LOOKUP_ONLYCONVERTING is set. From-SVN: r182496
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 3e6db51..29aed98 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1956,17 +1956,17 @@ add_function_candidate (struct z_candidate **candidates,
to handle move constructors and template constructors as well;
the standardese should soon be updated similarly. */
if (ctype && i == 0 && (len-skip == 1)
- && !(flags & LOOKUP_ONLYCONVERTING)
&& DECL_CONSTRUCTOR_P (fn)
&& parmtype != error_mark_node
&& (same_type_ignoring_top_level_qualifiers_p
(non_reference (parmtype), ctype)))
{
- lflags |= LOOKUP_COPY_PARM;
+ if (!(flags & LOOKUP_ONLYCONVERTING))
+ lflags |= LOOKUP_COPY_PARM;
/* We allow user-defined conversions within init-lists, but
don't list-initialize the copy parm, as that would mean
using two levels of braces for the same type. */
- if ((flags & LOOKUP_NO_COPY_CTOR_CONVERSION)
+ if ((flags & LOOKUP_LIST_INIT_CTOR)
&& BRACE_ENCLOSED_INITIALIZER_P (arg))
lflags |= LOOKUP_NO_CONVERSION;
}
@@ -3344,9 +3344,8 @@ add_list_candidates (tree fns, tree first_arg,
gcc_assert (*candidates == NULL);
- /* For list-initialization we consider explicit constructors, but
- give an error if one is selected. */
- flags &= ~LOOKUP_ONLYCONVERTING;
+ /* We're looking for a ctor for list-initialization. */
+ flags |= LOOKUP_LIST_INIT_CTOR;
/* And we don't allow narrowing conversions. We also use this flag to
avoid the copy constructor call for copy-list-initialization. */
flags |= LOOKUP_NO_NARROWING;
@@ -3374,8 +3373,6 @@ add_list_candidates (tree fns, tree first_arg,
flags &= ~LOOKUP_LIST_ONLY;
/* We allow more user-defined conversions within an init-list. */
flags &= ~LOOKUP_NO_CONVERSION;
- /* But not for the copy ctor. */
- flags |= LOOKUP_NO_COPY_CTOR_CONVERSION;
add_candidates (fns, first_arg, args, NULL_TREE,
explicit_targs, template_only, conversion_path,
@@ -4801,7 +4798,11 @@ add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args,
if (DECL_CONSTRUCTOR_P (fn))
{
check_list_ctor = !!(flags & LOOKUP_LIST_ONLY);
- check_converting = !!(flags & LOOKUP_ONLYCONVERTING);
+ /* For list-initialization we consider explicit constructors
+ and complain if one is chosen. */
+ check_converting
+ = ((flags & (LOOKUP_ONLYCONVERTING|LOOKUP_LIST_INIT_CTOR))
+ == LOOKUP_ONLYCONVERTING);
}
else
{