* c-typeck.c (readonly_error): Improve error for assignment.
* c-pretty-print.c (pp_c_additive_expression): Handle pointer-plus
expression.
(pp_c_expression): Ditto.
2007-08-09 Daniel Berlin <dberlin@dberlin.org>
* typeck2.c (readonly_error): Handle general expressions.
* error.c (dump_expr): Handle POINTER_PLUS_EXPR
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127320
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-08-09 Daniel Berlin <dberlin@dberlin.org>
+
+ * c-typeck.c (readonly_error): Improve error for assignment.
+
+ * c-pretty-print.c (pp_c_additive_expression): Handle pointer-plus
+ expression.
+ (pp_c_expression): Ditto.
+
2007-08-09 Simon Baldwin <simonb@google.com>
* simplify-rtx.c (simplify_binary_operation_1): Removed erroneous
enum tree_code code = TREE_CODE (e);
switch (code)
{
+ case POINTER_PLUS_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
pp_c_whitespace (pp);
- if (code == PLUS_EXPR)
+ if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
pp_plus (pp);
else
pp_minus (pp);
pp_conditional_expression (pp, e);
break;
+ case POINTER_PLUS_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
pp_c_additive_expression (pp, e);
G_("read-only variable %qD used as %<asm%> output")),
arg);
else
- error (READONLY_MSG (G_("assignment of read-only location"),
- G_("increment of read-only location"),
- G_("decrement of read-only location"),
- G_("read-only location used as %<asm%> output")));
+ error (READONLY_MSG (G_("assignment of read-only location %qE"),
+ G_("increment of read-only location %qE"),
+ G_("decrement of read-only location %qE"),
+ G_("read-only location %qE used as %<asm%> output")),
+ arg);
}
+2007-08-09 Daniel Berlin <dberlin@dberlin.org>
+
+ * typeck2.c (readonly_error): Handle general expressions.
+ * error.c (dump_expr): Handle POINTER_PLUS_EXPR
+
2007-08-06 Dan Hipschman <dsh@google.com>
* method.c (use_thunk): Use DECL_NAME instead of DECL_RTL to
dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
break;
+ case POINTER_PLUS_EXPR:
+ dump_binary_op ("+", t, flags);
+ break;
+
case INIT_EXPR:
case MODIFY_EXPR:
case PLUS_EXPR:
else if (TREE_CODE (arg) == FUNCTION_DECL)
error ("%s of function %qD", string, arg);
else
- error ("%s of read-only location", string);
+ error ("%s of read-only location %qE", string, arg);
}
\f
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+int func()
+{
+ const int *arr;
+ const int arr2[5];
+ arr[0] = 1; /* { dg-error "assignment of read-only location" "*(arr)" } */
+ arr[1] = 1; /* { dg-error "assignment of read-only location" "*(arr + 4u)" } */
+ arr2[0] = 1; /* { dg-error "assignment of read-only location" "arr2\[0\]" } */
+ arr2[1] = 1; /* { dg-error "assignment of read-only location" "arr2\[1\]" } */
+}