aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-10-23 18:08:10 +0000
committerJason Merrill <jason@redhat.com>2009-10-23 18:08:10 +0000
commit3c6454217c757cd055e82b15a8aa7014d885ac36 (patch)
tree03b3d3610bf66e9a807a7d17d876efd333e01e42
parent4321ac98e1fb20ab4f41d1dcc8cf411734516c71 (diff)
Core issue 899
* call.c (add_function_candidate): Only permit explicit conversion ops if copy ctor was called with a single argument. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153509 138bc75d-0d04-0410-961f-82ee72b054a4
-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 545634889b8..49a5ad2f4fd 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 fe74d15192f..45428045b84 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 334bbe5fa09..f42dd32ebda 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 00000000000..74726a99cad
--- /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" }
+}