In gcc/: 2011-01-12 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola.pero@meta-innovation.com>
Wed, 12 Jan 2011 09:36:49 +0000 (09:36 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Wed, 12 Jan 2011 09:36:49 +0000 (09:36 +0000)
In gcc/:
2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>

* c-parser.c (c_parser_objc_at_property_declaration): Improved
error message.

2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>

* c-parser.c (c_lex_one_token): Updated and reindented some
comments.  No changes in code.

In gcc/cp/:
2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>

* parser.c (cp_parser_objc_at_property_declaration): Improved
error message.

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

* objc.dg/property/at-property-29.m: New.
* obj-c++.dg/property/at-property-29.mm: New.

From-SVN: r168698

gcc/ChangeLog
gcc/c-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/property/at-property-29.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/property/at-property-29.m [new file with mode: 0644]

index a9bb4c2506b35c7746c31040b0de909932a7b7dc..1615efa643a4079d93c4c0645d88035d5f5c3326 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>     
+
+       * c-parser.c (c_parser_objc_at_property_declaration): Improved
+       error message.  
+       
+2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * c-parser.c (c_lex_one_token): Updated and reindented some
+       comments.  No changes in code.
+
 2011-01-11  Ian Lance Taylor  <iant@google.com>
 
        * godump.c (go_output_var): Don't output the variable if there is
index c9b529319ab14b53c9d36f0d99e23d140d411834..51df18886f4f0adf64c469d9ab211874252c7312 100644 (file)
@@ -253,8 +253,7 @@ c_lex_one_token (c_parser *parser, c_token *token)
                /* We found an Objective-C "pq" keyword (in, out,
                   inout, bycopy, byref, oneway).  They need special
                   care because the interpretation depends on the
-                  context.
-                */
+                  context.  */
                if (parser->objc_pq_context)
                  {
                    token->type = CPP_KEYWORD;
@@ -275,21 +274,19 @@ c_lex_one_token (c_parser *parser, c_token *token)
                       you can't use 'in' as the name of the running
                       variable in a C for loop.  We could potentially
                       try to add code here to disambiguate, but it
-                      seems a reasonable limitation.
-                   */
+                      seems a reasonable limitation.  */
                    token->type = CPP_KEYWORD;
                    token->keyword = rid_code;
                    break;
                  }
                /* Else, "pq" keywords outside of the "pq" context are
                   not keywords, and we fall through to the code for
-                  normal tokens.
-               */
+                  normal tokens.  */
              }
            else if (c_dialect_objc () && OBJC_IS_PATTR_KEYWORD (rid_code))
              {
-               /* We found an Objective-C "property attribute" keyword 
-                  (readonly, copies, getter, setter, ivar). These are 
+               /* We found an Objective-C "property attribute"
+                  keyword (getter, setter, readonly, etc). These are
                   only valid in the property context.  */
                if (parser->objc_property_attr_context)
                  {
@@ -310,8 +307,7 @@ c_lex_one_token (c_parser *parser, c_token *token)
                   protected, public, try, catch, throw) without a
                   preceding '@' sign.  Do nothing and fall through to
                   the code for normal tokens (in C++ we would still
-                  consider the CXX ones keywords, but not in C).
-               */
+                  consider the CXX ones keywords, but not in C).  */
                ;
              }
            else
@@ -7961,8 +7957,12 @@ c_parser_objc_at_property_declaration (c_parser *parser)
            case RID_SETTER:
              if (c_parser_next_token_is_not (parser, CPP_EQ))
                {
-                 c_parser_error (parser,
-                                 "getter/setter attribute must be followed by %<=%>");
+                 if (keyword == RID_GETTER)
+                   c_parser_error (parser,
+                                   "missing %<=%> (after %<getter%> attribute)");
+                 else
+                   c_parser_error (parser,
+                                   "missing %<=%> (after %<setter%> attribute)");
                  syntax_error = true;
                  break;
                }
index 95b8d183bf1753b40e2e05caf7e0bf40cbe7e522..0616dccc251c1d9cc952c3aa901ae51c7b760b96 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * parser.c (cp_parser_objc_at_property_declaration): Improved
+       error message.
+
 2011-01-11  Dodji Seketeli  <dodji@redhat.com>
 
        PR debug/46955
index 2f11f8ee90893ac48437b4bb9e7c050281018d62..e63d9765c58d1bbbe0e764aa09f583d7a5a3a5b1 100644 (file)
@@ -23087,8 +23087,12 @@ cp_parser_objc_at_property_declaration (cp_parser *parser)
            case RID_SETTER:
              if (cp_lexer_next_token_is_not (parser->lexer, CPP_EQ))
                {
-                 cp_parser_error (parser,
-                                  "getter/setter/ivar attribute must be followed by %<=%>");
+                 if (keyword == RID_GETTER)
+                   cp_parser_error (parser,
+                                    "missing %<=%> (after %<getter%> attribute)");
+                 else
+                   cp_parser_error (parser,
+                                    "missing %<=%> (after %<setter%> attribute)");
                  syntax_error = true;
                  break;
                }
@@ -23128,13 +23132,17 @@ cp_parser_objc_at_property_declaration (cp_parser *parser)
 
          if (syntax_error)
            break;
-         
+
          if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
            cp_lexer_consume_token (parser->lexer);
          else
            break;
        }
 
+      /* FIXME: "@property (setter, assign);" will generate a spurious
+        "error: expected ‘)’ before ‘,’ token".  This is because
+        cp_parser_require, unlike the C counterpart, will produce an
+        error even if we are in error recovery.  */
       if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
        {
          cp_parser_skip_to_closing_parenthesis (parser,
index 511ee6eab4667f7cc9d8043e063a1a4000d90a9f..15ffa935e81a4be517f4a833132040ff6c16e548 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-12  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/property/at-property-29.m: New.
+       * obj-c++.dg/property/at-property-29.mm: New.   
+       
 2011-01-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * go.test/go-test.exp (go-set-goarch): New proc.
diff --git a/gcc/testsuite/obj-c++.dg/property/at-property-29.mm b/gcc/testsuite/obj-c++.dg/property/at-property-29.mm
new file mode 100644 (file)
index 0000000..0f31617
--- /dev/null
@@ -0,0 +1,14 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, January 2011.  */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyRootClass
+{
+  Class isa;
+}
+/* Test missing '=' in setter/getter attributes.  */
+@property (getter)  int property_a; /* { dg-error "missing .=. .after .getter. attribute." } */
+@property (setter) int property_b;  /* { dg-error "missing .=. .after .setter. attribute." } */
+@property (assign, getter) int property_c; /* { dg-error "missing .=. .after .getter. attribute." } */
+@end
diff --git a/gcc/testsuite/objc.dg/property/at-property-29.m b/gcc/testsuite/objc.dg/property/at-property-29.m
new file mode 100644 (file)
index 0000000..0f31617
--- /dev/null
@@ -0,0 +1,14 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, January 2011.  */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyRootClass
+{
+  Class isa;
+}
+/* Test missing '=' in setter/getter attributes.  */
+@property (getter)  int property_a; /* { dg-error "missing .=. .after .getter. attribute." } */
+@property (setter) int property_b;  /* { dg-error "missing .=. .after .setter. attribute." } */
+@property (assign, getter) int property_c; /* { dg-error "missing .=. .after .getter. attribute." } */
+@end