In gcc/cp/: 2011-06-06 Nicola Pero <nicola.pero@meta-innovation.com>,
authorNicola Pero <nicola@gcc.gnu.org>
Mon, 6 Jun 2011 22:09:47 +0000 (22:09 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Mon, 6 Jun 2011 22:09:47 +0000 (22:09 +0000)
In gcc/cp/:
2011-06-06  Nicola Pero  <nicola.pero@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.

In gcc/testsuite/:
2011-06-06  Nicola Pero  <nicola.pero@meta-innovation.com>

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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/property/cxx-property-1.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/property/cxx-property-2.mm [new file with mode: 0644]

index dbe6ffb..c3826e5 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-06  Nicola Pero  <nicola.pero@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-06  Jason Merrill  <jason@redhat.com>
 
        PR c++/49298
index a410082..1d182a3 100644 (file)
@@ -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 %<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 *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:
index 7d9a9c2..889ba09 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-06  Nicola Pero  <nicola.pero@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-06  Jason Merrill  <jason@redhat.com>
 
        * 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 (file)
index 0000000..3c6f93e
--- /dev/null
@@ -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 (file)
index 0000000..4e085b3
--- /dev/null
@@ -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