diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 5523829f13c..562081b9876 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,10 @@ +2010-12-30 Nicola Pero + + * 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 PR objc/47118 diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 47f3fbc3792..bc959d6060b 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9019f79a188..a364a4e64ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-12-30 Nicola Pero + + * objc.dg/enhanced-proto-2.m: Updated. + * obj-c++.dg/enhanced-proto-2.mm: Updated. + 2010-12-29 Nicola Pero PR objc/47118 diff --git a/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm b/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm index 4aacbda8127..31c2e509b7a 100644 --- a/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm +++ b/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm @@ -11,9 +11,9 @@ @end @interface MyProto2 -@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 diff --git a/gcc/testsuite/objc.dg/enhanced-proto-2.m b/gcc/testsuite/objc.dg/enhanced-proto-2.m index 6944ec86627..c196b5151c9 100644 --- a/gcc/testsuite/objc.dg/enhanced-proto-2.m +++ b/gcc/testsuite/objc.dg/enhanced-proto-2.m @@ -12,9 +12,9 @@ @end @interface MyProto2 -@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