This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [Patch, ObjC/C++] Recognize attributes on class, category and protocol declarations.
- From: "Nicola Pero" <nicola dot pero at meta-innovation dot com>
- To: "IainS" <developer at sandoe-acoustics dot co dot uk>
- Cc: "GCC Patches" <gcc-patches at gcc dot gnu dot org>, "Mike Stump" <mrs at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>, "Jason Merrill" <jason at redhat dot com>
- Date: Sun, 26 Sep 2010 16:26:47 +0200 (CEST)
- Subject: RE: [Patch, ObjC/C++] Recognize attributes on class, category and protocol declarations.
- References: <C97DAA0C-0D72-429A-A276-ADA2FE3090E1@sandoe-acoustics.co.uk>
I haven't looked at the details, but the patch looks very cool :-)
I wonder about the warning messages though. They mention "ObjC Version 1",
but I'm not even sure I know myself what "ObjC Version 1" is ;-)
I would suggest we use something more neutral (for now), such as
class attributes are ignored (not supported by the compiler)
We'll need to classify and document the Objective-C features as we're going to be
adding all the new ones, so we may want to revisit the message once we have done
some classification (which should probably go in the gcc/doc/standards.texi).
Thanks
-----Original Message-----
From: "IainS" <developer@sandoe-acoustics.co.uk>
Sent: Sunday, 26 September, 2010 16:04
To: "GCC Patches" <gcc-patches@gcc.gnu.org>
Cc: "Mike Stump" <mrs@gcc.gnu.org>, "Joseph S. Myers" <joseph@codesourcery.com>, "Jason Merrill" <jason@redhat.com>, "Nicola Pero" <nicola.pero@meta-innovation.com>
Subject: [Patch, ObjC/C++] Recognize attributes on class, category and protocol declarations.
Hi,
The patch implements the parsing for the prefix attributes on class,
category and protocol in both ObjC and ObjC++ FEs and hands off the
result to the shared code in objc-act (which simply raises a warning
that the attribute is currently ignored).
This is part of the support needed for (eventually) ObjC V1 and (as
soon as possible) to parse Application/Foundation headers on NeXT
platforms >= Darwin9.
Nicola came up with the approach and started the patch off - I tweaked
the c parts and added the c++ , objc-act and testsuite bits.
We feel that this approach is useful in that:
(a) the remainder of the implementation can be local to objc/ and..
(b) instead of a fatal syntax error, we now have a warning which may
often be ignored safely on m32 NeXT (the main use in system headers is
to warn of deprecated interfaces that become unavailable at m64).
The source locations shown in diagnostics could be better, but that's
for a different patch.
Tested on i686-darwin9, x86_64-unknown-linux-gnu, and on a cross to
mipsisa64-elf
We need approval for c, c-family, c++ and objc.
OK to apply?
Iain
gcc/c-family:
* c-common.h (objc_start_class_interface): Adjust prototype.
(objc_start_category_interface): Likewise.
(objc_start_protocol): Likewise.
* stub-objc.c (objc_start_protocol): Adjust for extra argument.
(objc_start_class_interface): Likewise.
(objc_start_category_interface): Likewise.
gcc/objc:
* objc-act.c (objc_start_class_interface): Handle and ignore
attributes.
(objc_start_category_interface): Likewise.
(objc_start_protocol): Likewise.
gcc/cp:
* parser.c (objc_at_keyword_follows_attributes): New.
(cp_parser_declaration): Parse prefix attributes for ObjC++.
(cp_parser_objc_protocol_declaration): Handle attributes.
(cp_parser_objc_class_interface): Likewise.
(cp_parser_objc_declaration): Likewise.
gcc:
* c-parser.c (c_parser_objc_class_definition): Adjust prototype.
(c_parser_objc_protocol_definition): Likewise.
(c_parser_external_declaration): Provide dummy attribute arguments.
(c_parser_declaration_or_fndef): Parse prefix attributes for ObjC.
(c_parser_objc_class_definition): Handle attributes.
(c_parser_objc_protocol_definition): Likewise.
gcc/testsuite:
* objc.dg/attributes: New.
* objc.dg/attributes/attributes.exp: New.
* objc.dg/attributes/class-attribute-1.m: New.
* objc.dg/attributes/class-attribute-2.m: New
* objc.dg/attributes/categ-attribute-1.m: New
* objc.dg/attributes/categ-attribute-2.m: New
* objc.dg/attributes/proto-attribute-1.m: New
* obj-c++.dg/attributes: New.
* obj-c++.dg/attributes/attributes.exp: New
* obj-c++.dg/attributes/class-attribute-1.mm: New
* obj-c++.dg/attributes/class-attribute-2.mm: New
* obj-c++.dg/attributes/categ-attribute-1.mm: New
* obj-c++.dg/attributes/categ-attribute-2.mm: New
* obj-c++.dg/attributes/proto-attribute-1.mm: New