Core issue 899

Core issue 899
	* call.c (add_function_candidate): Only permit explicit conversion
	ops if copy ctor was called with a single argument.

From-SVN: r153509
This commit is contained in:
Jason Merrill 2009-10-23 14:08:10 -04:00 committed by Jason Merrill
parent fc77a3d812
commit 78dd7466f8
4 changed files with 28 additions and 1 deletions

View File

@ -1,5 +1,9 @@
2009-10-23 Jason Merrill <jason@redhat.com>
Core issue 899
* call.c (add_function_candidate): Only permit explicit conversion
ops if copy ctor was called with a single argument.
* call.c (initialize_reference): Tweak error message.
2009-10-21 Jakub Jelinek <jakub@redhat.com>

View File

@ -1631,7 +1631,8 @@ add_function_candidate (struct z_candidate **candidates,
parmtype = build_pointer_type (parmtype);
}
if (ctype && i == 0 && DECL_COPY_CONSTRUCTOR_P (fn))
if (ctype && i == 0 && DECL_COPY_CONSTRUCTOR_P (fn)
&& (len-skip == 1))
{
/* Hack: Direct-initialize copy parm (i.e. suppress
LOOKUP_ONLYCONVERTING) to make explicit conversion ops

View File

@ -1,3 +1,8 @@
2009-10-23 Jason Merrill <jason@redhat.com>
Core issue 899
* g++.dg/cpp0x/explicit4.C: New.
2009-10-23 Joseph Myers <joseph@codesourcery.com>
* g++.dg/abi/rtti3.C, g++.dg/abi/thunk4.C: Skip for *-*-mingw* and

View File

@ -0,0 +1,17 @@
// Negative explicit conv test.
// { dg-options "-std=c++0x" }
struct A {
A(const A&, int = 0); // { dg-message "candidates" }
};
struct B
{
explicit operator A();
};
int main()
{
B b;
(A(b)); // OK
(A(b,1)); // { dg-error "no match" }
}