-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
This issue was copied from checkedc/checkedc-clang#42
This change implements checking of type requirements for bounds declarations for variables, members, and function return values. It implements the checking described in Chapter 3 and Chapter 5 (interoperation) of the Checked C specification. This addresses Github issue #41.
The requirements in Chapter 3 include:
- Bounds declaration are not allowed for variables, members, and return values with ptr type.
- They are also not allowed for function types and function pointer types.
- Count bounds expressions are allowed for variables or members that have pointer type or array type. They are also allowed for pointer-typed function return values. The pointer type must be a non-void pointer type.
byte_count
andbounds
bounds expressions are allowed for variables and members with pointer or array types. They are also allowed for pointer-typed function return values..
The interoperation requirements include:
- Local variables with unchecked pointer or array types cannot have bounds declared for them. Other declarations (global variables, members, and function return values) with unchecked pointer or array types can have bounds declared for them. This is how bounds-safe interfaces are described.
- Integer-typed variables, members, and return values can have bounds declared for them using
byte_count
orbounds
expressions
This change also:
- Fixes the implementation of clang type tests for BoundsExpr and its subclasses. The static classof methods were not implemented. In addition, the kind information for CountBoundsExpr and NullaryBoundsExpr was not properly padded, so it was overwriting the superclass kind information.
- Renames ActOnBoundsExpr to ActOnBoundsDecl, to more accurately describe what the function is doing.
Testing:
- New tests have been added to typechecking\bounds.c. This will be committed separately to the GitHub CheckedC repo. The new tests systematically test the cross product of variable/member/function return bounds declarations, the different kinds of bounds expressions, and the different types of variables.
- Passes existing clang tests.
Metadata
Metadata
Assignees
Labels
No labels