From: Jason Merrill Date: Wed, 25 May 2011 19:51:44 +0000 (-0400) Subject: re PR c++/46696 ([C++0x] Implicit copy constructor can't construct array of subtype... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e24286319abceaee8846843c89c5c6332d25e51;p=gcc.git re PR c++/46696 ([C++0x] Implicit copy constructor can't construct array of subtype with user-defined copy constructor.) PR c++/46696 * typeck.c (cp_build_modify_expr): Check DECL_DEFAULTED_FN. From-SVN: r174226 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 236ca6d090a..72e62d75f70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-05-25 Jason Merrill + PR c++/46696 + * typeck.c (cp_build_modify_expr): Check DECL_DEFAULTED_FN. + PR c++/47184 * parser.c (cp_parser_parameter_declaration): Recognize list-initialization. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 69b25d39645..5fbb765767e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6748,7 +6748,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, /* Allow array assignment in compiler-generated code. */ else if (!current_function_decl - || !DECL_ARTIFICIAL (current_function_decl)) + || !DECL_DEFAULTED_FN (current_function_decl)) { /* This routine is used for both initialization and assignment. Make sure the diagnostic message differentiates the context. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 10b928f3b79..833d52eb635 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-05-25 Jason Merrill + * g++.dg/cpp0x/defaulted29.C: New. + * g++.dg/cpp0x/initlist51.C: New. 2011-05-25 Janis Johnson diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted29.C b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C new file mode 100644 index 00000000000..5fcf5b0c543 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C @@ -0,0 +1,20 @@ +// PR c++/46696 +// { dg-options -std=c++0x } + +struct A +{ + A& operator= (A const&); +}; + +struct B +{ + A ar[1]; + B& operator= (B const&) = default; +}; + +int main() +{ + B x; + B y; + y = x; +}