]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/44358
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 Jun 2010 03:55:28 +0000 (03:55 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 Jun 2010 03:55:28 +0000 (03:55 +0000)
* call.c (build_list_conv): Set list-initialization flags properly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160131 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist36.C [new file with mode: 0644]

index 594431300d48f8a13f5e4f955ee9ea3803b9777e..1cb2baf84d7e3ee2f7f1c2d05dac01e069828346 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/44358
+       * call.c (build_list_conv): Set list-initialization flags properly.
+
 2010-06-01  Nathan Froyd  <froydnj@codesourcery.com>
 
        * typeck2.c (build_x_arrow): Make types_memoized a VEC.
index 64e2e50278762cb75f9e55fdd0d1dd09185e799e..40627025ae7a694a997a8c979f54e23a269fd804 100644 (file)
@@ -589,6 +589,12 @@ build_list_conv (tree type, tree ctor, int flags)
   unsigned i;
   tree val;
 
+  /* Within a list-initialization we can have more user-defined
+     conversions.  */
+  flags &= ~LOOKUP_NO_CONVERSION;
+  /* But no narrowing conversions.  */
+  flags |= LOOKUP_NO_NARROWING;
+
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
     {
       conversion *sub
index cd4fdc359fc3a06baa343d7ede626104de02f2be..3bdfeff37bcf618d6bc66b452f14b4ff585dc5cb 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/44358
+       * g++.dg/cpp0x/initlist36.C: New.
+
 2010-05-31 Jan Hubicka  <jh@suse.cz>
 
        * testsuite/gcc.dg/noreturn-8.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist36.C b/gcc/testsuite/g++.dg/cpp0x/initlist36.C
new file mode 100644 (file)
index 0000000..a3305e1
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/44358
+// { dg-options "-std=c++0x" }
+
+#include <initializer_list>
+
+struct A
+{
+  A(int);
+};
+
+struct B
+{
+  B(std::initializer_list<A>);
+};
+
+void f (B b);
+int main()
+{
+  B b0 = {{1}};
+  B b1 = {{1.0}};              // { dg-error "narrowing" }
+}