After a long discussion on the mailing list
https://sourceforge.net/p/sdcc/mailman/message/31801282/
this came out.
The following code should generate error 10: lvalue required:
char E=0, b=1;
++E = b;
as the spec says that ++E is equivalent to (E+=1) which is not an lvalue.
After I made ++E an rvalue *++E started to fail. I believe this is wrong because * should turn an rvalue into an lvalue, right ? But this check in SDCCast.c line 3666 is already present from day 1 ?! Further I get the feeling most expressions are marked neither lvalue nor rvalue and slip through many tests.
It might also be that I totally misunderstand the lvalue and rvalue fields and that they don't mark the AST to BE an lvalue/rvalue but to REQUIRE an lvalue/rvalue.
The same goes for (E++)[1] which fails in SDCCast.c line 3120 after my mod. But (p+1)[1] is still ok, because (p+1) is marked neither lvalue nor rvalue.
I really don't get it. In SDCCast.c lines 3229-3243 the operand of ++ or -- is marked lvalue, no matter if it really is one or not. IMO that is too late. It should check whether the operand is an lvalue instead. And IMO it should mark the ast as rvalue. Can anyone explain?
Bug is still exists.
Any ideas?
While I remember having fixed some lvalue vs. rvalue stuff a few months ago, this bug still exists in current SDCC.
My rvalue fixes a few month ago might not have been fixed this bug, but nearly. Just one more line was needed. Fixed in [r14248].
Related
Commit: [r14248]