aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-12-19 15:10:37 -0500
committerJason Merrill <jason@gcc.gnu.org>2011-12-19 15:10:37 -0500
commit00ef7059049de2761ed8c9db8839ce3566d09cb7 (patch)
treee44c01cd576e9d5ca4c9bd0aaa9ba03120617938 /gcc
parentd58d6eb5eca0451638d50752f3cbcc40084c4116 (diff)
downloadgcc-00ef7059049de2761ed8c9db8839ce3566d09cb7.zip
gcc-00ef7059049de2761ed8c9db8839ce3566d09cb7.tar.gz
gcc-00ef7059049de2761ed8c9db8839ce3566d09cb7.tar.bz2
re PR c++/51553 (brace initialization and conversion operators)
PR c++/51553 * call.c (add_function_candidate): Allow conversions for the copy parm in list-initialization unless the argument is an init-list. From-SVN: r182495
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist64.C29
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d9e1949..e440087 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-19 Jason Merrill <jason@redhat.com>
+
+ PR c++/51553
+ * call.c (add_function_candidate): Allow conversions for the copy
+ parm in list-initialization unless the argument is an init-list.
+
2011-12-19 Jakub Jelinek <jakub@redhat.com>
PR c++/51619
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index dd716a4..3e6db51 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1964,8 +1964,10 @@ add_function_candidate (struct z_candidate **candidates,
{
lflags |= LOOKUP_COPY_PARM;
/* We allow user-defined conversions within init-lists, but
- not for the copy constructor. */
- if (flags & LOOKUP_NO_COPY_CTOR_CONVERSION)
+ 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)
+ && BRACE_ENCLOSED_INITIALIZER_P (arg))
lflags |= LOOKUP_NO_CONVERSION;
}
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 70c3315..d08c3ad 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-12-19 Jason Merrill <jason@redhat.com>
+ PR c++/51553
+ * g++.dg/cpp0x/initlist64.C: New.
+
PR c++/51228
* c-c++-common/transparent-union-1.c: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist64.C b/gcc/testsuite/g++.dg/cpp0x/initlist64.C
new file mode 100644
index 0000000..337e89b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist64.C
@@ -0,0 +1,29 @@
+// PR c++/51553
+// { dg-options -std=c++0x }
+
+struct X
+{
+ X();
+};
+
+struct Y
+{
+ operator X() const;
+};
+
+struct Z
+{
+ explicit operator X() const;
+};
+
+X a = { Y() };
+X aa = Y();
+
+X b{ Y() };
+X bb(Y());
+
+X c = { Z() }; // { dg-error "" "" { xfail *-*-* } }
+X cc = Z(); // { dg-error "" }
+
+X d{ Z() };
+X dd( Z() );