Hi, Sébastien
Simply, if a expression(simply or complicated combinative expression) return a value which can designates an object(has MEMORY), it is a lvalue.
i do not think lvalue has some consequent relation with operators.
Under your rewrite rules, ++a also has half possibility NOT a lvalue.
;-)



2014/1/4 Sebastien Lorquet <sebastien@lorquet.fr>
hello

I agree with what you have written in your above message.

however until now I still can't decide if an affectation operator
expression is an lvalue or not.

lvalues are more elaborate that just mere identifiers, the unary *
applied to any expression also forms a valid lvalue, as well as the
indexing operation [].

Here is what I found:
http://ieng9.ucsd.edu/~cs30x/Lvalues%20and%20Rvalues.htm

They don't mention affectation operators...

I think I found a convincing reason for not semantically accepting this
construct:

Using the unusual comma operator [1]"," ++a could be (sort-of)
rewritten as : a=a+1,a
so ++a = b; would be a=a+1,a = b;

[1] http://en.wikipedia.org/wiki/Comma_operator

On the contrary a++ = b would be rewritten a,a=a+1=b which would
probably fail because in 'a+1=b", a+1 is not an lvalue for sure.

but since in C, IIRC, the order of evaluation is not guaranteed, then
the two versions may be considered equivalent, and the decision seems
not to consider ++a as an lvalue.

At least gcc thinks that neither a++ nor ++a are lvalues.

Sébastien Lorquet


Le vendredi 3 janvier 2014 17:36:40, feqin fan a écrit :
> ++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
> <mailto: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.
>
>     Maarten
>
>     ------------------------------------------------------------------------------
>     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!
>     http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>     _______________________________________________
>     sdcc-devel mailing list
>     sdcc-devel@lists.sourceforge.net <mailto:sdcc-devel@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/sdcc-devel
>
>
>
>
> --
> 业精于勤,荒于嬉..
>
>
> ------------------------------------------------------------------------------
> 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!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>
>
> _______________________________________________
> sdcc-devel mailing list
> sdcc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-devel

------------------------------------------------------------------------------
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!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
sdcc-devel mailing list
sdcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-devel



--
业精于勤,荒于嬉..