aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-10-23 14:08:10 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-10-23 14:08:10 -0400
commit78dd7466f8143975212a874e72a0ffc843c09a94 (patch)
tree03b3d3610bf66e9a807a7d17d876efd333e01e42
parentfc77a3d812da1434af68b9c3831314170cb9de2e (diff)
downloadgcc-78dd7466f8143975212a874e72a0ffc843c09a94.zip
gcc-78dd7466f8143975212a874e72a0ffc843c09a94.tar.gz
gcc-78dd7466f8143975212a874e72a0ffc843c09a94.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/explicit4.C17
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5456348..49a5ad2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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>
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index fe74d15..4542804 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 334bbe5..f42dd32 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit4.C b/gcc/testsuite/g++.dg/cpp0x/explicit4.C
new file mode 100644
index 0000000..74726a9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/explicit4.C
@@ -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" }
+}