aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-12-03 02:47:13 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2013-12-03 02:47:13 +0000
commit4c2ecab0e4978f3a4a5b40fe595729b30375386a (patch)
treeeb299deee08e7335f846ed167c65364ef8d62b64 /gcc/c
parentf9153cba636597ca403e56a2302f05233c4e85a7 (diff)
downloadgcc-4c2ecab0e4978f3a4a5b40fe595729b30375386a.zip
gcc-4c2ecab0e4978f3a4a5b40fe595729b30375386a.tar.gz
gcc-4c2ecab0e4978f3a4a5b40fe595729b30375386a.tar.bz2
re PR c/58235 (Missing diagnostic on assignment to array in c89)
PR c/58235 c: * c-typeck.c (build_modify_expr): Diagnose assignment to expression with array type. testsuite: * gcc.dg/c90-array-lval-8.c: New test. From-SVN: r205615
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c8
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index a106e64..42b0bb7 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-02 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/58235
+ * c-typeck.c (build_modify_expr): Diagnose assignment to
+ expression with array type.
+
2013-11-29 Joseph Myers <joseph@codesourcery.com>
PR c/42262
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 4d70104..672a564 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -5205,6 +5205,14 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
return error_mark_node;
+ /* Ensure an error for assigning a non-lvalue array to an array in
+ C90. */
+ if (TREE_CODE (lhstype) == ARRAY_TYPE)
+ {
+ error_at (location, "assignment to expression with array type");
+ return error_mark_node;
+ }
+
/* For ObjC properties, defer this check. */
if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
return error_mark_node;