return true;
}
+static bool is_lvalue(const expression_t *expression)
+{
+ switch (expression->kind) {
+ case EXPR_REFERENCE:
+ case EXPR_ARRAY_ACCESS:
+ case EXPR_SELECT:
+ case EXPR_UNARY_DEREFERENCE:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
static void semantic_incdec(unary_expression_t *expression)
{
type_t *const orig_type = expression->value->base.type;
"operation needs an arithmetic or pointer type");
return;
}
+ if (!is_lvalue(expression->value)) {
+ /* TODO: improve error message */
+ errorf(&expression->base.source_position, "lvalue required as operand");
+ }
expression->base.type = orig_type;
}
return false;
}
-static bool is_lvalue(const expression_t *expression)
-{
- switch (expression->kind) {
- case EXPR_REFERENCE:
- case EXPR_ARRAY_ACCESS:
- case EXPR_SELECT:
- case EXPR_UNARY_DEREFERENCE:
- return true;
-
- default:
- return false;
- }
-}
-
static bool is_valid_assignment_lhs(expression_t const* const left)
{
type_t *const orig_type_left = revert_automatic_type_conversion(left);