Commit 611d6f76 by Jason Merrill Committed by Jason Merrill

re PR c++/41510 ([C++0x] std::complex vs. initialization lists)

	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.

From-SVN: r159792
parent e20463aa
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> 2010-05-24 Nathan Froyd <froydnj@codesourcery.com>
* rtti.c (tinfo_base_init): Use build_constructor instead of * rtti.c (tinfo_base_init): Use build_constructor instead of
......
...@@ -6350,7 +6350,8 @@ build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args, ...@@ -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)) && BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *args, 0))
&& CONSTRUCTOR_IS_DIRECT_INIT (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); list = VEC_index (tree, *args, 0);
if (TYPE_HAS_LIST_CTOR (basetype)) if (TYPE_HAS_LIST_CTOR (basetype))
......
...@@ -5278,7 +5278,6 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) ...@@ -5278,7 +5278,6 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
error ("in C++98 %qD must be initialized by constructor, " error ("in C++98 %qD must be initialized by constructor, "
"not by %<{...}%>", "not by %<{...}%>",
decl); decl);
init = build_tree_list (NULL_TREE, init);
} }
else if (TREE_CODE (type) == VECTOR_TYPE && TYPE_VECTOR_OPAQUE (type)) else if (TREE_CODE (type) == VECTOR_TYPE && TYPE_VECTOR_OPAQUE (type))
{ {
......
...@@ -1240,7 +1240,9 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) ...@@ -1240,7 +1240,9 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
TREE_READONLY (exp) = 0; TREE_READONLY (exp) = 0;
TREE_THIS_VOLATILE (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; flags |= LOOKUP_ONLYCONVERTING;
if (TREE_CODE (type) == ARRAY_TYPE) if (TREE_CODE (type) == ARRAY_TYPE)
......
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> 2010-05-24 Paul Brook <paul@codesourcery.com>
* gcc.target/arm/frame-pointer-1.c: New test. * gcc.target/arm/frame-pointer-1.c: New test.
......
// 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>();
...@@ -6,7 +6,7 @@ struct A { ...@@ -6,7 +6,7 @@ struct A {
}; };
struct B { struct B {
B(const B&); // { dg-message "candidate" } B(const B&);
int b; int b;
}; };
...@@ -19,7 +19,7 @@ int main() ...@@ -19,7 +19,7 @@ int main()
int i = { 1 }; int i = { 1 };
int j = { 1, 2 }; /* { dg-error "requires one element" } */ int j = { 1, 2 }; /* { dg-error "requires one element" } */
A a = { 6 }; /* { dg-error "initialize" } */ 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" } */ C c = { 6 }; /* { dg-error "too many initializers" } */
D d = { 6 }; D d = { 6 };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment