lcc icon indicating copy to clipboard operation
lcc copied to clipboard

Fixed the result of unary + to generate rvalue

Open mycoboco opened this issue 9 years ago • 0 comments

Given an lvalue as an operand of the unary +, lcc generates an lvalue even if it should not. Thus,

void foo(void)
{
    int x, *p;
    p = &+x;
    +x = 0;
}

it silently accepts this incorrect code.

A simple fix for this issue is to make a RIGHT tree when the result of + is an lvalue, as done in constructing cast trees.

mycoboco avatar Mar 10 '15 00:03 mycoboco