-
- Downloads
C-Family, Objective-C : Implement Objective-C nullability Part 1[PR90707].
This part of the implementation covers property nullability attributes and includes the changes to common code. Follow-on changes will be needed to cover Objective-C method definitions, but those are expected to be local to the Objective-C front end. The basis of the implementation is to translate the Objective-C-specific keywords into an attribute (objc_nullability) which has the required states to carry the attribute markup. We introduce the keywords, and these are parsed and validated in the same manner as other property attributes. The resulting value is attached to the property as an objc_nullability attribute. gcc/c-family/ChangeLog: PR objc/90707 * c-common.c (c_common_reswords): null_unspecified, nullable, nonnull, null_resettable: New keywords. * c-common.h (enum rid): RID_NULL_UNSPECIFIED, RID_NULLABLE, RID_NONNULL, RID_NULL_RESETTABLE: New. (OBJC_IS_PATTR_KEYWORD): Include nullability keywords in the ranges accepted for property attributes. * c-attribs.c (handle_objc_nullability_attribute): New. * c-objc.h (enum objc_property_attribute_group): Add OBJC_PROPATTR_GROUP_NULLABLE. (enum objc_property_attribute_kind):Add OBJC_PROPERTY_ATTR_NULL_UNSPECIFIED, OBJC_PROPERTY_ATTR_NULLABLE, OBJC_PROPERTY_ATTR_NONNULL, OBJC_PROPERTY_ATTR_NULL_RESETTABLE. gcc/objc/ChangeLog: PR objc/90707 * objc-act.c (objc_prop_attr_kind_for_rid): Handle nullability. (objc_add_property_declaration): Handle nullability attributes. Check that these are applicable to the property type. * objc-act.h (enum objc_property_nullability): New. gcc/testsuite/ChangeLog: PR objc/90707 * obj-c++.dg/property/at-property-4.mm: Add basic nullability tests. * objc.dg/property/at-property-4.m: Likewise. * obj-c++.dg/attributes/nullability-00.mm: New test. * obj-c++.dg/property/nullability-00.mm: New test. * objc.dg/attributes/nullability-00.m: New test. * objc.dg/property/nullability-00.m: New test. gcc/ChangeLog: PR objc/90707 * doc/extend.texi: Document the objc_nullability attribute.
Showing
- gcc/c-family/c-attribs.c 49 additions, 0 deletionsgcc/c-family/c-attribs.c
- gcc/c-family/c-common.c 6 additions, 0 deletionsgcc/c-family/c-common.c
- gcc/c-family/c-common.h 6 additions, 1 deletiongcc/c-family/c-common.h
- gcc/c-family/c-objc.h 5 additions, 0 deletionsgcc/c-family/c-objc.h
- gcc/doc/extend.texi 27 additions, 0 deletionsgcc/doc/extend.texi
- gcc/objc/objc-act.c 50 additions, 1 deletiongcc/objc/objc-act.c
- gcc/objc/objc-act.h 10 additions, 0 deletionsgcc/objc/objc-act.h
- gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm 20 additions, 0 deletionsgcc/testsuite/obj-c++.dg/attributes/nullability-00.mm
- gcc/testsuite/obj-c++.dg/property/at-property-4.mm 19 additions, 1 deletiongcc/testsuite/obj-c++.dg/property/at-property-4.mm
- gcc/testsuite/obj-c++.dg/property/nullability-00.mm 21 additions, 0 deletionsgcc/testsuite/obj-c++.dg/property/nullability-00.mm
- gcc/testsuite/objc.dg/attributes/nullability-00.m 20 additions, 0 deletionsgcc/testsuite/objc.dg/attributes/nullability-00.m
- gcc/testsuite/objc.dg/property/at-property-4.m 18 additions, 0 deletionsgcc/testsuite/objc.dg/property/at-property-4.m
- gcc/testsuite/objc.dg/property/nullability-00.m 21 additions, 0 deletionsgcc/testsuite/objc.dg/property/nullability-00.m
Loading
Please register or sign in to comment