From: Erik P. <epe...@iv...> - 2014-01-03 02:18:51
|
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 |