Objective-C/C++ (parsers) : Update @property attribute parsing.
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 31 Oct 2020 20:53:34 +0000 (20:53 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Fri, 6 Nov 2020 19:49:23 +0000 (19:49 +0000)
commit9a34a5cce6b50fc3527e7c7ab356808ed435883c
treea1b114d1c1f375371c8eb1cf69025a15d99dfb80
parent6c282c14d1be0bba2bf5d49acd074b349f28ad17
Objective-C/C++ (parsers) : Update @property attribute parsing.

At present, we are missing parsing and checking for around
half of the property attributes in use.  The existing ad hoc scheme
for the parser's communication with the Objective C validation
is not suitable for extending to cover all the missing cases.

Additionally:

1/ We were declaring errors in two cases that the reference
   implementation warns (or is silent).

   I've elected to warn for both those cases, (Wattributes) it
   could be that we should implement Wobjc-xxx-property warning
   masks (TODO).

2/ We were emitting spurious complaints about missing property
   attributes when these were not being parsed because we gave
   up on the first syntax error.

3/ The quality of the diagnostic locations was poor (that's
   true for much of Objective-C, we will have to improve it as
   we modernise areas).

We continue to attempt to keep the code, warning and error output
similar (preferably identical output) between the C and C++ front
ends.

The interface to the Objective-C-specific parts of the parsing is
simplified to a vector of parsed (but not fully-checked) property
attributes, this will simplify the addition of new attributes.

gcc/c-family/ChangeLog:

* c-objc.h (enum objc_property_attribute_group): New
(enum objc_property_attribute_kind): New.
(OBJC_PROPATTR_GROUP_MASK): New.
(struct property_attribute_info): Small class encapsulating
parser output from property attributes.
(objc_prop_attr_kind_for_rid): New
(objc_add_property_declaration): Simplify interface.
* stub-objc.c (enum rid): Dummy type.
(objc_add_property_declaration): Simplify interface.
(objc_prop_attr_kind_for_rid): New.

gcc/c/ChangeLog:

* c-parser.c (c_parser_objc_at_property_declaration):
Improve parsing fidelity. Associate better location info
with @property attributes.  Clean up the interface to
objc_add_property_declaration ().

gcc/cp/ChangeLog:

* parser.c (cp_parser_objc_at_property_declaration):
Improve parsing fidelity. Associate better location info
with @property attributes.  Clean up the interface to
objc_add_property_declaration ().

gcc/objc/ChangeLog:

* objc-act.c (objc_prop_attr_kind_for_rid): New.
(objc_add_property_declaration): Adjust to consume the
parser output using a vector of parsed attributes.

gcc/testsuite/ChangeLog:

* obj-c++.dg/property/at-property-1.mm: Adjust expected
diagnostics.
* obj-c++.dg/property/at-property-29.mm: Likewise.
* obj-c++.dg/property/at-property-4.mm: Likewise.
* obj-c++.dg/property/property-neg-2.mm: Likewise.
* objc.dg/property/at-property-1.m: Likewise.
* objc.dg/property/at-property-29.m: Likewise.
* objc.dg/property/at-property-4.m: Likewise.
* objc.dg/property/at-property-5.m: Likewise.
* objc.dg/property/property-neg-2.m: Likewise.
14 files changed:
gcc/c-family/c-objc.h
gcc/c-family/stub-objc.c
gcc/c/c-parser.c
gcc/cp/parser.c
gcc/objc/objc-act.c
gcc/testsuite/obj-c++.dg/property/at-property-1.mm
gcc/testsuite/obj-c++.dg/property/at-property-29.mm
gcc/testsuite/obj-c++.dg/property/at-property-4.mm
gcc/testsuite/obj-c++.dg/property/property-neg-2.mm
gcc/testsuite/objc.dg/property/at-property-1.m
gcc/testsuite/objc.dg/property/at-property-29.m
gcc/testsuite/objc.dg/property/at-property-4.m
gcc/testsuite/objc.dg/property/at-property-5.m
gcc/testsuite/objc.dg/property/property-neg-2.m