From: Mark Mitchell Date: Wed, 14 Jun 2006 19:18:45 +0000 (+0000) Subject: re PR c++/28018 (g++.dg/ext/complit1.C fails: in emit_move_insn, at expr.c:3275) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf24598a2e455e30465a5c00f6be8b31fe8f7a79;p=gcc.git re PR c++/28018 (g++.dg/ext/complit1.C fails: in emit_move_insn, at expr.c:3275) PR c++/28018 * typeck.c (build_modify_expr): Disallow array assignment. PR c++/28018 * g++.old-deja/g++.benjamin/14664-2.C: Expect error for array assignment. * g++.old-deja/g++.pt/crash51.C: Likewise. From-SVN: r114653 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ccf6b26a246..b0fc888475f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2006-06-14 Mark Mitchell + + PR c++/28018 + * typeck.c (build_modify_expr): Disallow array assignment. + 2006-06-14 Gabriel Dos Reis * cp-tree.def: Fix typo. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a47c35e64fb..5602ef2baa2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5707,7 +5707,10 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs) /* Allow array assignment in compiler-generated code. */ if (! DECL_ARTIFICIAL (current_function_decl)) - pedwarn ("ISO C++ forbids assignment of arrays"); + { + error ("array used as initializer"); + return error_mark_node; + } from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE ? 1 + (modifycode != INIT_EXPR): 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2760477d778..b5d4925883f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2006-06-14 Mark Mitchell + PR c++/28018 + * g++.old-deja/g++.benjamin/14664-2.C: Expect error for array + assignment. + * g++.old-deja/g++.pt/crash51.C: Likewise. + PR c++/27227 * g++.dg/lookup/linkage1.C: New test. * g++.dg/lookup/linkage2.C: Likewise. diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C index 468953bc6c1..364f30c4b27 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C @@ -7,9 +7,7 @@ char foo[26]; void bar() { - // the addition of the flag "-fno-const-string-literal" reverts to pre-ISO. - // -g++: ANSI C++ forbids assignment of arrays - foo = "0123456789012345678901234"; // WARNING - + foo = "0123456789012345678901234"; // { dg-error "array" } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash51.C b/gcc/testsuite/g++.old-deja/g++.pt/crash51.C index d851a3b0f7f..a3fbc17f163 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash51.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash51.C @@ -7,7 +7,7 @@ char foo[26]; template void f () { - foo = "0123456789012345678901234"; + foo = "0123456789012345678901234"; // { dg-error "array" } } template void f();