Skip to content

Type Qualifier modifiers problem #147

@counc009

Description

@counc009

The way that the applyMods (and applyLhsRhsMods) functions work to apply RuntimeMods causes problems with lot of the productions they can operate on, because the function uses stmtExpr in wrapping the modified expressions. Because of this, any injectable production that expects an lValue (such as pre and post increment and decrement) will fail if we try to use qualifiers to modify the expression (since a stmtExpr must always be an rValue).
I think it is safe to remove this stmtExpr, the risk this introduces would be for the original expression to be evaluated multiple times, however using a stmtExpr means that anywhere that requires an lValue will be an error.
Looking at a longer term fix to this, it seems like the model used for handling qualifiers in CallExpr might work better in general, where it is possible to inject Stmt before and after the expression itself, transforming the expression into a stmtExpr that does setup, evaluates the expression, and then does more afterwards, finally returning the value from the function call. This model would work for any production that produces an rValue. The only productions I can think of that produce lValues are the dereferenceExpr and arraySubscriptExpr, though in both of these cases the children are rValues, and so a stmtExpr for each child can be used.
I don't know whether this is the correct fix, or what it is, but I thought it was something worth bringing up. I'm going to make a pull request for the initial idea (just removing the stmtExpr), but I think further discussion of how to better handle this may be needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions