Skip to content

Parse bounds expressions in function parameter list scopes. #17

@secure-sw-dev-bot

Description

@secure-sw-dev-bot

This issue was copied from checkedc/checkedc-clang#17


This change addresses issue #7 (process bounds expressions for parameters
with all the parameters available). Currently, bounds expressions for
parameters are being parsed and type checked in the scope of the parameters
seen so far in a parameter list. They need to be typechecked in a scope with
all the parameters for the parameter list.

To do this, parsing and type checking of bounds expressions for parameters
is deferred until the entire parameter list has been seen. This is done
in two steps. During the initial parse, the tokens for a superset of bounds
expressions are parsed and stored in a list. They are then re-parsed using
ParseBoundsExpression after all parameters have been seen.

This change also improves error messages when a bounds expression is parsed
with misspelled contextual keyword. For example, int x : boounds(x, x + 5).
Before, the code would simply give up after parsing the misspelled keyword
and the '('. This led to additional error messages when the code tried to
match the closing ')'. This fix is to skip all the tokens up to but not
including the closing ')'.

Testing:

  • Passes existing clang test suite.
  • Added additional tests for parsing of function parameter lists with bounds
    expressions. This will be committed separately to the Checked C repo.

Metadata

Metadata

Assignees

No one assigned

    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