From 889ec77132ca388f1d4a3349db729564969feac2 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Mon, 6 Jun 2011 22:09:47 +0000 Subject: [PATCH] In gcc/cp/: 2011-06-06 Nicola Pero , In gcc/cp/: 2011-06-06 Nicola Pero , PR obj-c++/48275 * parser.c (cp_parser_objc_at_property_declaration): Allow setter and getter names to use all the allowed method names. In gcc/testsuite/: 2011-06-06 Nicola Pero PR objc-++/48275 * obj-c++.dg/property/cxx-property-1.mm: New. * obj-c++.dg/property/cxx-property-2.mm: New. From-SVN: r174726 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/parser.c | 18 +++++++++------ gcc/testsuite/ChangeLog | 6 +++++ .../obj-c++.dg/property/cxx-property-1.mm | 10 +++++++++ .../obj-c++.dg/property/cxx-property-2.mm | 22 +++++++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/obj-c++.dg/property/cxx-property-1.mm create mode 100644 gcc/testsuite/obj-c++.dg/property/cxx-property-2.mm diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dbe6ffbc555..c3826e5559c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-06-06 Nicola Pero , + + 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-06 Jason Merrill PR c++/49298 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a41008225fa..1d182a396b1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23187,7 +23187,7 @@ cp_parser_objc_at_property_declaration (cp_parser *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 *parser) if (keyword == RID_SETTER) { if (property_setter_ident != NULL_TREE) - cp_parser_error (parser, "the % attribute may only be specified once"); + { + cp_parser_error (parser, "the % 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 *parser) else { if (property_getter_ident != NULL_TREE) - cp_parser_error (parser, "the % attribute may only be specified once"); + { + cp_parser_error (parser, "the % 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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7d9a9c2ef9f..889ba09d700 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-06-06 Nicola Pero + + PR objc-++/48275 + * obj-c++.dg/property/cxx-property-1.mm: New. + * obj-c++.dg/property/cxx-property-2.mm: New. + 2011-06-06 Jason Merrill * g++.dg/cpp0x/regress/ptrmem1.C: New. diff --git a/gcc/testsuite/obj-c++.dg/property/cxx-property-1.mm b/gcc/testsuite/obj-c++.dg/property/cxx-property-1.mm new file mode 100644 index 00000000000..3c6f93e2a42 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/cxx-property-1.mm @@ -0,0 +1,10 @@ +/* Testcase from PR obj-c++/48275. */ +/* { dg-do compile } */ + +@interface Test +{ + int ns; +} +@property (getter=namespace) int ns; + +@end diff --git a/gcc/testsuite/obj-c++.dg/property/cxx-property-2.mm b/gcc/testsuite/obj-c++.dg/property/cxx-property-2.mm new file mode 100644 index 00000000000..4e085b39824 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/cxx-property-2.mm @@ -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