+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
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;
+2013-12-02 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/58235
+ * gcc.dg/c90-array-lval-8.c: New test.
+
2013-12-02 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/59358
--- /dev/null
+/* Test for non-lvalue arrays: test that they cannot be assigned to
+ array variables. PR 58235. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+struct s { char c[1]; } x;
+struct s f (void) { return x; }
+
+void
+g (void)
+{
+ char c[1];
+ c = f ().c; /* { dg-error "array" } */
+}
+
+void
+h (void)
+{
+ char c[1] = f ().c; /* { dg-error "array" } */
+}