You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of Checked C in clang allows dimensions of multi-dimensional arrays to have different checked properties. A dimension could be declared as unchecked by prefixing it with the unchecked keyword. The Checked C specification says all dimensions of multi-dimensional arrays have to either be all checked or all unchecked. We thought about changing the spec, but have decided to stick with it because allowing dimensions to have different checked properties is confusing.
This changes removes the ability to use the `unchecked' keyword to declare unchecked dimensions for multi-dimensional arrays (addressing GitHub issue #27). In addition, it adds error checking that dimensions in a multi-dimensional array are either all checked or unchecked.
There are some corner cases to handle due to typedefs. In C, an array is an array of arrays. A typedef can define an array type that is used as a nested array type. The case where the enclosing array and the nested array differ in their checked property because of a typedef is now an error. We take some care to generate an error message that explains what is going on.
In addition, we also have to handle parenthesized types. The checked property for a multi-dimensional array propagates from the outer array type to inner array types declared as part of the a declaration (int a checked[10][10] declares a checked array of checked arrays). Testing for this change uncovered that the checked property was not being propagating properly to nested types when a declarator was parenthesized (int (a checked[10])[10]). This change fixes that.
Testing:
Wrote new feature tests for testing that array dimensions have consistent checked properties. This changes will be checked in separately to the Checked C repo in typechecking\checked_arrays.c.
Wrote new feature tests for testing parenthesized array declarators for checked arrays.
Code still passes the existing clang baseline tests.
The text was updated successfully, but these errors were encountered:
Hi @dtarditi, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
It looks like you're a Microsoft contributor (David Tarditi). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.
This issue was copied from checkedc/checkedc-clang#32
The implementation of Checked C in clang allows dimensions of multi-dimensional arrays to have different checked properties. A dimension could be declared as unchecked by prefixing it with the
unchecked
keyword. The Checked C specification says all dimensions of multi-dimensional arrays have to either be all checked or all unchecked. We thought about changing the spec, but have decided to stick with it because allowing dimensions to have different checked properties is confusing.This changes removes the ability to use the `unchecked' keyword to declare unchecked dimensions for multi-dimensional arrays (addressing GitHub issue #27). In addition, it adds error checking that dimensions in a multi-dimensional array are either all checked or unchecked.
There are some corner cases to handle due to typedefs. In C, an array is an array of arrays. A typedef can define an array type that is used as a nested array type. The case where the enclosing array and the nested array differ in their checked property because of a typedef is now an error. We take some care to generate an error message that explains what is going on.
In addition, we also have to handle parenthesized types. The checked property for a multi-dimensional array propagates from the outer array type to inner array types declared as part of the a declaration (int a checked[10][10] declares a checked array of checked arrays). Testing for this change uncovered that the checked property was not being propagating properly to nested types when a declarator was parenthesized (int (a checked[10])[10]). This change fixes that.
Testing:
The text was updated successfully, but these errors were encountered: