diff mbox

ObjC/ObjC+: tidy up error messages for @optional/@required

Message ID 12CD6497-2F7A-4E60-BDFB-157B1B03BA32@meta-innovation.com
State New
Headers show

Commit Message

Nicola Pero Dec. 29, 2010, 10:49 p.m. UTC
This patch tidies up the error messages for @optional/@required.

Ok to commit ?

Thanks

@protocol context only" }  */
  - (void) FOO3;
  @end

Comments

Mike Stump Dec. 29, 2010, 10:53 p.m. UTC | #1
On Dec 29, 2010, at 2:49 PM, Nicola Pero wrote:
> This patch tidies up the error messages for @optional/@required.
> 
> Ok to commit ?

Ok.
diff mbox

Patch

Index: objc/objc-act.c
===================================================================
--- objc/objc-act.c     (revision 168326)
+++ objc/objc-act.c     (working copy)
@@ -876,13 +876,21 @@  void
  objc_set_method_opt (bool optional)
  {
    if (flag_objc1_only)
-    error_at (input_location, "@optional/@required are not available  
in Objective-C 1.0");
+    {
+      if (optional)
+       error_at (input_location, "%<@optional%> is not available in  
Objective-C 1.0");
+      else
+       error_at (input_location, "%<@required%> is not available in  
Objective-C 1.0");
+    }

    objc_method_optional_flag = optional;
    if (!objc_interface_context
        || TREE_CODE (objc_interface_context) !=  
PROTOCOL_INTERFACE_TYPE)
      {
-      error ("@optional/@required is allowed in @protocol context  
only");
+      if (optional)
+       error ("%<@optional%> is allowed in @protocol context only");
+      else
+       error ("%<@required%> is allowed in @protocol context only");
        objc_method_optional_flag = false;
      }
  }
Index: objc/ChangeLog
===================================================================
--- objc/ChangeLog      (revision 168326)
+++ objc/ChangeLog      (working copy)
@@ -1,3 +1,10 @@ 
+2010-12-30  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc-act.c (objc_set_method_opt): Tidy up error messages.  In
+       particular, explicitly mention whether the error is due to the
+       @optional or @required keyword instead of mentioning
+       "@optional/@required".
+
  2010-12-29  Nicola Pero  <nicola.pero@meta-innovation.com>

         PR objc/47118
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 168326)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@ 
+2010-12-30  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/enhanced-proto-2.m: Updated.
+       * obj-c++.dg/enhanced-proto-2.mm: Updated.
+
  2010-12-29  Nicola Pero  <nicola.pero@meta-innovation.com>

         PR objc/47118
Index: testsuite/objc.dg/enhanced-proto-2.m
===================================================================
--- testsuite/objc.dg/enhanced-proto-2.m        (revision 168323)
+++ testsuite/objc.dg/enhanced-proto-2.m        (working copy)
@@ -12,9 +12,9 @@ 
  @end

  @interface  MyProto2 <MyProto1>
-@required              /* { dg-error "@optional/@required is allowed  
in @protocol context only" }  */
+@required              /* { dg-error ".@required. is allowed in  
@protocol context only" }  */
  - (void) FOO2;
-@optional              /* { dg-error "@optional/@required is allowed  
in @protocol context only" }  */
+@optional              /* { dg-error ".@optional. is allowed in  
@protocol context only" }  */
  - (void) FOO3;
  @end

Index: testsuite/obj-c++.dg/enhanced-proto-2.mm
===================================================================
--- testsuite/obj-c++.dg/enhanced-proto-2.mm    (revision 168323)
+++ testsuite/obj-c++.dg/enhanced-proto-2.mm    (working copy)
@@ -11,9 +11,9 @@ 
  @end

  @interface  MyProto2 <MyProto1>
-@required              /* { dg-error "@optional/@required is allowed  
in @protocol context only" }  */
+@required              /* { dg-error ".@required. is allowed in  
@protocol context only" }  */
  - (void) FOO2;
-@optional              /* { dg-error "@optional/@required is allowed  
in @protocol context only" }  */
+@optional              /* { dg-error ".@optional. is allowed in