OSDN Git Service

PR c++/28018
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Jun 2006 19:18:45 +0000 (19:18 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Jun 2006 19:18:45 +0000 (19:18 +0000)
* 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.

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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C
gcc/testsuite/g++.old-deja/g++.pt/crash51.C

index ccf6b26..b0fc888 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-14  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/28018
+       * typeck.c (build_modify_expr): Disallow array assignment.
+
 2006-06-14  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * cp-tree.def: Fix typo.
index a47c35e..5602ef2 100644 (file)
@@ -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;
index 2760477..b5d4925 100644 (file)
@@ -1,5 +1,10 @@
 2006-06-14  Mark Mitchell  <mark@codesourcery.com>
 
+       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.
index 468953b..364f30c 100644 (file)
@@ -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" }
 }
 
 
index d851a3b..a3fbc17 100644 (file)
@@ -7,7 +7,7 @@ char foo[26];
 template <class T>
 void f ()
 {
-  foo = "0123456789012345678901234";  
+  foo = "0123456789012345678901234"; // { dg-error "array" }
 }
 
 template void f<int>();