++a is a expression but NOT a identifier, so it not a lvalue.
An lvalue designates an object(means has memory allocated).
if the variable a is a pointer variable, *(++a) will be a lvalue. 

2014/1/3 Maarten Brock <sourceforge.brock@dse.nl>
> On Fri, 3 Jan 2014, Maarten Brock wrote:
>>>> I have two detailed questions regarding to the SDCC.y,
>>>> 1. At line 468 - 470
>>>>> assignment_expr
>>>>>    : conditional_expr
>>>>>    | cast_expr assignment_operator assignment_expr
>>>> The above rule allows the following code is accepted:
>>>>> long mul2(long a, long b)
>>>>> {
>>>>>         ++a = b;
>>>>>         return a * b;
>>>>> }
>> Is "++a" a cast expression? I would expect that to be "(sometype)a".
>> Maarten
> It's also a cast expression as far as the grammar is concerned because
> cast expressions also match unary operator expressions.
> Looking back 9 years, I see I changed the grammar from "unary_expr
> assignment_operator assignment_expr" to "cast_expr assignment_operator
> assignment_expr" so that lvalue casts could at least be parsed. This way
> it could be rejected with a more helpful "lvalue required" error message
> rather than a generic syntax error message. See this ticket for the
> background:
>      http://sourceforge.net/p/sdcc/bugs/813/
>    Erik

Ah, that clears things up. So now only the question remains whether "++a"
is an lvalue or not. If it is (and I see no reason why not) then SDCC is
correct. Anyway SDCC generates as can be expected for "++a = b", whether a
is volatile or not.


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
sdcc-devel mailing list