Opened 11 months ago

#205 new defect

Incorrect Lvalues On Expressions

Reported by: ajbeach Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

There are a some expressions we do not choose the correct lvalue for an expression. Unfortunately some of these are used incorrectly in some other places in the code base so multiple fixes would be required.

The places lvalue does not match C are:

Cast Expressions: C casts are never lvalues, currently they pass through the lvalueness of their argument. - Other types of casts seem to be working properly.

Member Expressions: These should be lvalues only if the left hand side is an lvalue. Currently they are always lvalues. - Untyped member expressions do the check which does suggest this was a hack at some point.

Comma Expressions: These should never be lvalues, currently they are lvalues if there right-hand-side is an lvalue.

Constant Expressions: Currently never lvalues, however string literals should be lvalues. Although maybe just for & which is a no-op in this situation.

Name Expressions: Function names and enumeration value names are not lvalues. Function names are kind of special in a way that it sort of works out. Enumeration values though are represented with names and should be rvalues.

Additional Notes: We don't have to match C's understanding of lvalue on input (as long as we handle it properly) but we do have to on our C output. As we only have one mechanism to handle both for now they are going to have to match. Statement Expressions are non-standard and are not consistently lvalues, it depends on the compiler and for safety we assume they never are lvalues. If you need more information lvalue is one of the value categories in C, try looking that up.

Change History (0)

Note: See TracTickets for help on using tickets.