Can I apply this fix to the 4.6 branch as well ? Some users are asking for it to be backported to the 4.6 branch.
It's not a regression, because the property implementation is new in GCC 4.6, but it is still a serious bug if you're trying to use properties with ObjC++, as you can't use "namespace" as a getter name. It's a simple fix, quite obvious, and very limited in scope (even if it was wrong, it can't really do much harm other than breaking property declarations in ObjC++ which are already broken without the patch), so I'd go for it. OK to commit to the 4.6 branch ? Thanks On 6 Jun 2011, at 20:22, Nicola Pero wrote: > This patch fixes PR obj-c++/48275. It's a routine parser ingenuity. > > OK to commit ? > > Thanks > > Index: testsuite/ChangeLog > =================================================================== > --- testsuite/ChangeLog (revision 174657) > +++ testsuite/ChangeLog (working copy) > @@ -1,3 +1,9 @@ > +2011-06-06 Nicola Pero <nicola.p...@meta-innovation.com> > + > + PR objc-++/48275 > + * obj-c++.dg/property/cxx-property-1.mm: New. > + * obj-c++.dg/property/cxx-property-2.mm: New. > + > 2011-06-05 Nicola Pero <nicola.p...@meta-innovation.com> > > PR testsuite/49287 > Index: testsuite/obj-c++.dg/property/cxx-property-2.mm > =================================================================== > --- testsuite/obj-c++.dg/property/cxx-property-2.mm (revision 0) > +++ testsuite/obj-c++.dg/property/cxx-property-2.mm (revision 0) > @@ -0,0 +1,22 @@ > +/* { dg-do compile } */ > + > +/* All these C++ keywords are acceptable in ObjC method names, hence > + should be accepted for property getters and setters. */ > + > +@interface Test > +{ > + Class isa; > +} > +@property (getter=namespace) int p0; > +@property (setter=namespace:) int p1; > +@property (getter=and) int p2; > +@property (setter=and:) int p3; > +@property (getter=class) int p4; > +@property (setter=class:) int p5; > +@property (getter=new) int p6; > +@property (setter=new:) int p7; > +@property (getter=delete) int p8; > +@property (setter=delete:) int p9; > +@property (getter=delete) int p10; > +@property (setter=delete:) int p11; > +@end > Index: testsuite/obj-c++.dg/property/cxx-property-1.mm > =================================================================== > --- testsuite/obj-c++.dg/property/cxx-property-1.mm (revision 0) > +++ testsuite/obj-c++.dg/property/cxx-property-1.mm (revision 0) > @@ -0,0 +1,10 @@ > +/* Testcase from PR obj-c++/48275. */ > +/* { dg-do compile } */ > + > +@interface Test > +{ > + int ns; > +} > +@property (getter=namespace) int ns; > + > +@end > Index: cp/ChangeLog > =================================================================== > --- cp/ChangeLog (revision 174656) > +++ cp/ChangeLog (working copy) > @@ -1,3 +1,9 @@ > +2011-06-06 Nicola Pero <nicola.p...@meta-innovation.com>, > + > + PR obj-c++/48275 > + * parser.c (cp_parser_objc_at_property_declaration): Allow setter > + and getter names to use all the allowed method names. > + > 2011-06-04 Jonathan Wakely <jwakely....@gmail.com> > > * init.c (build_delete): Warn when deleting type with non-virtual > Index: cp/parser.c > =================================================================== > --- cp/parser.c (revision 174656) > +++ cp/parser.c (working copy) > @@ -23187,7 +23187,7 @@ cp_parser_objc_at_property_declaration (cp_parser > break; > } > cp_lexer_consume_token (parser->lexer); /* eat the = */ > - if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME)) > + if (!cp_parser_objc_selector_p (cp_lexer_peek_token > (parser->lexer)->type)) > { > cp_parser_error (parser, "expected identifier"); > syntax_error = true; > @@ -23196,10 +23196,12 @@ cp_parser_objc_at_property_declaration (cp_parser > if (keyword == RID_SETTER) > { > if (property_setter_ident != NULL_TREE) > - cp_parser_error (parser, "the %<setter%> attribute may > only be specified once"); > + { > + cp_parser_error (parser, "the %<setter%> attribute may > only be specified once"); > + cp_lexer_consume_token (parser->lexer); > + } > else > - property_setter_ident = cp_lexer_peek_token > (parser->lexer)->u.value; > - cp_lexer_consume_token (parser->lexer); > + property_setter_ident = cp_parser_objc_selector (parser); > if (cp_lexer_next_token_is_not (parser->lexer, CPP_COLON)) > cp_parser_error (parser, "setter name must terminate with > %<:%>"); > else > @@ -23208,10 +23210,12 @@ cp_parser_objc_at_property_declaration (cp_parser > else > { > if (property_getter_ident != NULL_TREE) > - cp_parser_error (parser, "the %<getter%> attribute may > only be specified once"); > + { > + cp_parser_error (parser, "the %<getter%> attribute may > only be specified once"); > + cp_lexer_consume_token (parser->lexer); > + } > else > - property_getter_ident = cp_lexer_peek_token > (parser->lexer)->u.value; > - cp_lexer_consume_token (parser->lexer); > + property_getter_ident = cp_parser_objc_selector (parser); > } > break; > default: >