Skip to content

Handling C style casts in checking free variables #911

Closed
@dopelsunce

Description

@dopelsunce
void f() {
  int a1 checked[5];
  short int t20 : byte_count(5 * sizeof(int)) = (short int)a1;
}

a1 and t20 are incorrectly reported as free variables by #903.

This causes one test to fail: checkedc/tests/typechecking/bounds.c

When checking the assignment,
EquivExprs contains the set { LValueToRValue(t20), (short int)LValueToRValue(a1) } and we're searching for the variable LValueToRValue(a1). Thus a1 and t20 are treated unequal.

Fix: this could be part of #909 to add DeclRefExprs to the variable set, and then search the EquivExprs for an expression that is the DeclRefExpr ignoring casts and parentheses.

Basically add a IsRValueCastOfVariableIgnoringCasts method that would return true for (short int)LValueToRValue(a1) and DeclRefExpr(a1)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions