diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist26.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist28.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist33.C | 13 |
6 files changed, 34 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c62f817..beedb80 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-05-10 Jason Merrill <jason@redhat.com> + + PR c++/44045 + * typeck.c (cp_build_modify_expr): Complain about assignment to + array from init list. + 2010-05-10 Fabien ChĂȘne <fabien.chene@gmail.com> PR c++/43719 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 61d5f22..5c8fd826 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6634,6 +6634,12 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, if (BRACE_ENCLOSED_INITIALIZER_P (newrhs)) { + if (modifycode != INIT_EXPR) + { + if (complain & tf_error) + error ("assigning to an array from an initializer list"); + return error_mark_node; + } if (check_array_initializer (lhs, lhstype, newrhs)) return error_mark_node; newrhs = digest_init (lhstype, newrhs); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f76632..9f0a4b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-05-10 Jason Merrill <jason@redhat.com> + + PR c++/44045 + * g++.dg/cpp0x/initlist33.C: New. + * g++.dg/cpp0x/initlist26.C: Adjust. + * g++.dg/cpp0x/initlist28.C: Adjust. + 2010-05-10 Fabien ChĂȘne <fabien.chene@gmail.com> PR c++/43719 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist26.C b/gcc/testsuite/g++.dg/cpp0x/initlist26.C index 645e74f..bb28bdb 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist26.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist26.C @@ -6,5 +6,5 @@ void foo (int i) { int a[i]; - a = { }; // { dg-error "may not be initialized" } + a = { }; // { dg-error "assign" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist28.C b/gcc/testsuite/g++.dg/cpp0x/initlist28.C index 3b959a0..d1df7cb 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist28.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist28.C @@ -4,5 +4,5 @@ void foo() { int a[1]; - throw a = {}; // { dg-error "invalid use of non-lvalue array" } + throw a = {}; // { dg-error "assign" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist33.C b/gcc/testsuite/g++.dg/cpp0x/initlist33.C new file mode 100644 index 0000000..b1c0ba0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist33.C @@ -0,0 +1,13 @@ +// PR c++/44045 +// { dg-options "-std=c++0x" } + +struct base +{ + virtual ~base() { } +}; + +int main() +{ + base ptr_array[1]; + ptr_array = { base() }; // { dg-error "assign" } +} |