OSDN Git Service

PR c++/41510
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2010 18:38:16 +0000 (18:38 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2010 18:38:16 +0000 (18:38 +0000)
* decl.c (check_initializer): Don't wrap an init-list in a
TREE_LIST.
* init.c (build_aggr_init): Don't assume copy-initialization if
init has CONSTRUCTOR_IS_DIRECT_INIT.
* call.c (build_new_method_call): Sanity check.

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

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

index b0454e6..2a3a8a0 100644 (file)
@@ -1,3 +1,12 @@
+2010-05-24  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41510
+       * decl.c (check_initializer): Don't wrap an init-list in a
+       TREE_LIST.
+       * init.c (build_aggr_init): Don't assume copy-initialization if
+       init has CONSTRUCTOR_IS_DIRECT_INIT.
+       * call.c (build_new_method_call): Sanity check.
+
 2010-05-24  Nathan Froyd  <froydnj@codesourcery.com>
 
        * rtti.c (tinfo_base_init): Use build_constructor instead of
index 3cb30a5..890ab88 100644 (file)
@@ -6350,7 +6350,8 @@ build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args,
       && BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *args, 0))
       && CONSTRUCTOR_IS_DIRECT_INIT (VEC_index (tree, *args, 0)))
     {
-      gcc_assert (VEC_length (tree, *args) == 1);
+      gcc_assert (VEC_length (tree, *args) == 1
+                 && !(flags & LOOKUP_ONLYCONVERTING));
       list = VEC_index (tree, *args, 0);
 
       if (TYPE_HAS_LIST_CTOR (basetype))
index 95ae8eb..5420f71 100644 (file)
@@ -5278,7 +5278,6 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
                error ("in C++98 %qD must be initialized by constructor, "
                       "not by %<{...}%>",
                       decl);
-             init = build_tree_list (NULL_TREE, init);
            }
          else if (TREE_CODE (type) == VECTOR_TYPE && TYPE_VECTOR_OPAQUE (type))
            {
index 1fb5eb0..bf80c09 100644 (file)
@@ -1240,7 +1240,9 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
   TREE_READONLY (exp) = 0;
   TREE_THIS_VOLATILE (exp) = 0;
 
-  if (init && TREE_CODE (init) != TREE_LIST)
+  if (init && TREE_CODE (init) != TREE_LIST
+      && !(BRACE_ENCLOSED_INITIALIZER_P (init)
+          && CONSTRUCTOR_IS_DIRECT_INIT (init)))
     flags |= LOOKUP_ONLYCONVERTING;
 
   if (TREE_CODE (type) == ARRAY_TYPE)
index a0b34c9..eb1361d 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-24  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41510
+       * g++.dg/cpp0x/initlist35.C: New.
+       * g++.dg/init/brace6.C: Adjust.
+
 2010-05-24  Paul Brook  <paul@codesourcery.com>
 
        * gcc.target/arm/frame-pointer-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist35.C b/gcc/testsuite/g++.dg/cpp0x/initlist35.C
new file mode 100644 (file)
index 0000000..e5b7cb4
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/41510
+// { dg-options "-std=c++0x" }
+
+struct B
+{
+  B(int, int);
+};
+struct A
+{
+  A(int, int);
+  A(const B&);
+};
+
+void f()
+{
+  A a = { 1, 2 };
+};
+
+template <class T> void g()
+{
+  A a = { 1, 2 };
+};
+
+template void g<int>();
index bff89da..96b35b0 100644 (file)
@@ -6,7 +6,7 @@ struct A {
 };
 
 struct B {
-   B(const B&);                        // { dg-message "candidate" }
+   B(const B&);
    int b;
 };
 
@@ -19,7 +19,7 @@ int main()
    int i = { 1 };
    int j = { 1, 2 }; /* { dg-error "requires one element" } */
    A a = { 6 }; /* { dg-error "initialize" } */
-   B b = { 6 }; /* { dg-error "initialize" } */
+   B b = { 6 }; /* { dg-error "" } */
    C c = { 6 }; /* { dg-error "too many initializers" } */
    D d = { 6 };
 }