diff options
author | iains <iains@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-17 13:02:07 +0000 |
---|---|---|
committer | iains <iains@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-17 13:02:07 +0000 |
commit | 4a8875ed04bdb950589f3bdd2ddbb69fc910f94a (patch) | |
tree | 4cf60cd36ea1bba58842294fad70214ca02f74bc /gcc | |
parent | 8e03fb20974e43b5302f7c4f3548b3bf41352e25 (diff) | |
download | gcc-4a8875ed04bdb950589f3bdd2ddbb69fc910f94a.tar.gz |
add parse support for @package to ObjC*
gcc/c-family:
* c-common.c (c_common_reswords): Add package, RID_AT_PACKAGE.
* c-common.h (enum rid): Add RID_AT_PACKAGE.
(objc_ivar_visibility_kind): New enum.
(objc_set_visibility): Adjust prototype to use visibility enum.
* stub-objc.c (objc_set_visibility): Adjust stub to use
visibility enum.
gcc/objc:
* objc-act.c: Rename 'objc_public_flag' to objc_ivar_visibility and
make its type 'objc_ivar_visibility_kind'.
(objc_start_class_interface): Update to use visibility enum.
(objc_start_class_implementation): Likewise.
(objc_set_visibility): Update to use visibility enum, warn that
@package is handle as per @public.
(add_instance_variable): Handle OBJC_IVAR_VIS_PACKAGE.
* objc-act.h: Rename 'objc_public_flag' to objc_ivar_visibility and
make its type 'objc_ivar_visibility_kind'.
gcc/cp:
* parser.c (cp_parser_objc_visibility_spec): Update to use visibility
enum, and handle @package.
gcc:
* c-parser.c (c_parser_objc_class_instance_variables): Update to use
visibility enum, and handle @package.
gcc/testsuite:
* objc.dg/fsf-package-0.m: New.
* obj-c++.dg/fsf-package-0.m: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165585 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 1 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 12 | ||||
-rw-r--r-- | gcc/c-family/stub-objc.c | 2 | ||||
-rw-r--r-- | gcc/c-parser.c | 12 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 9 | ||||
-rw-r--r-- | gcc/objc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 31 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/fsf-package-0.m | 37 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/fsf-package-0.m | 37 |
14 files changed, 156 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 47254d31f12..512ae120dbc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-10-17 Iain Sandoe <iains@gcc.gnu.org> + + * c-parser.c (c_parser_objc_class_instance_variables): Update to use + visibility enum, and handle @package. + 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> * doc/objc.texi (What you can and what you cannot do in +load): diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 29fc3a1e37d..f0ef49e0171 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2010-10-17 Iain Sandoe <iains@gcc.gnu.org> + + * c-common.c (c_common_reswords): Add package, RID_AT_PACKAGE. + * c-common.h (enum rid): Add RID_AT_PACKAGE. + (objc_ivar_visibility_kind): New enum. + (objc_set_visibility): Adjust prototype to use visibility enum. + * stub-objc.c (objc_set_visibility): Adjust stub to use + visibility enum. + 2010-10-14 Michael Meissner <meissner@linux.vnet.ibm.com> * c-cppbuiltin.c (builtin_define_float_constants): Emit diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 5203c0538ee..5068c56f5ed 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -544,6 +544,7 @@ const struct c_common_resword c_common_reswords[] = { "optional", RID_AT_OPTIONAL, D_OBJC }, { "required", RID_AT_REQUIRED, D_OBJC }, { "property", RID_AT_PROPERTY, D_OBJC }, + { "package", RID_AT_PACKAGE, D_OBJC }, /* These are recognized only in protocol-qualifier context (see above) */ { "bycopy", RID_BYCOPY, D_OBJC }, diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 8c79d27d9dd..8855ff794d3 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -143,7 +143,7 @@ enum rid they follow '@') */ RID_AT_ENCODE, RID_AT_END, RID_AT_CLASS, RID_AT_ALIAS, RID_AT_DEFS, - RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC, + RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC, RID_AT_PACKAGE, RID_AT_PROTOCOL, RID_AT_SELECTOR, RID_AT_THROW, RID_AT_TRY, RID_AT_CATCH, RID_AT_FINALLY, RID_AT_SYNCHRONIZED, @@ -440,6 +440,14 @@ typedef enum objc_property_attribute_kind { OBJC_PATTR_COPIES = 5 } objc_property_attribute_kind; +/* ObjC ivar visibility types. */ +typedef enum objc_ivar_visibility_kind { + OBJC_IVAR_VIS_PROTECTED = 0, + OBJC_IVAR_VIS_PUBLIC = 1, + OBJC_IVAR_VIS_PRIVATE = 2, + OBJC_IVAR_VIS_PACKAGE = 3 +} objc_ivar_visibility_kind; + /* The various name of operator that appears in error messages. */ typedef enum ref_operator { /* NULL */ @@ -1009,7 +1017,7 @@ extern void objc_start_class_implementation (tree, tree); extern void objc_start_category_implementation (tree, tree); extern void objc_continue_implementation (void); extern void objc_finish_implementation (void); -extern void objc_set_visibility (int); +extern void objc_set_visibility (objc_ivar_visibility_kind); extern void objc_set_method_type (enum tree_code); extern tree objc_build_method_signature (tree, tree, tree, bool); extern void objc_add_method_declaration (tree, tree); diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c index 4a8a2b56b8e..cff4d79267e 100644 --- a/gcc/c-family/stub-objc.c +++ b/gcc/c-family/stub-objc.c @@ -163,7 +163,7 @@ objc_add_instance_variable (tree ARG_UNUSED (decl)) } void -objc_set_visibility (int ARG_UNUSED (vis)) +objc_set_visibility (objc_ivar_visibility_kind ARG_UNUSED (vis)) { } diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 36ed95131f1..e4230b97382 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -6703,19 +6703,25 @@ c_parser_objc_class_instance_variables (c_parser *parser) if (c_parser_next_token_is_keyword (parser, RID_AT_PRIVATE)) { c_parser_consume_token (parser); - objc_set_visibility (2); + objc_set_visibility (OBJC_IVAR_VIS_PRIVATE); continue; } else if (c_parser_next_token_is_keyword (parser, RID_AT_PROTECTED)) { c_parser_consume_token (parser); - objc_set_visibility (0); + objc_set_visibility (OBJC_IVAR_VIS_PROTECTED); continue; } else if (c_parser_next_token_is_keyword (parser, RID_AT_PUBLIC)) { c_parser_consume_token (parser); - objc_set_visibility (1); + objc_set_visibility (OBJC_IVAR_VIS_PUBLIC); + continue; + } + else if (c_parser_next_token_is_keyword (parser, RID_AT_PACKAGE)) + { + c_parser_consume_token (parser); + objc_set_visibility (OBJC_IVAR_VIS_PACKAGE); continue; } else if (c_parser_next_token_is (parser, CPP_PRAGMA)) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 16b930793ed..b72d43d2ae6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-10-17 Iain Sandoe <iains@gcc.gnu.org> + + * parser.c (cp_parser_objc_visibility_spec): Update to use visibility + enum, and handle @package. + 2010-10-15 Jason Merrill <jason@redhat.com> PR c++/45983 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3e02cd500d2..670337e5f46 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21356,13 +21356,16 @@ cp_parser_objc_visibility_spec (cp_parser* parser) switch (vis->keyword) { case RID_AT_PRIVATE: - objc_set_visibility (2); + objc_set_visibility (OBJC_IVAR_VIS_PRIVATE); break; case RID_AT_PROTECTED: - objc_set_visibility (0); + objc_set_visibility (OBJC_IVAR_VIS_PROTECTED); break; case RID_AT_PUBLIC: - objc_set_visibility (1); + objc_set_visibility (OBJC_IVAR_VIS_PUBLIC); + break; + case RID_AT_PACKAGE: + objc_set_visibility (OBJC_IVAR_VIS_PACKAGE); break; default: return; diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 1a51c1444ff..7917d60fa9b 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,15 @@ +2010-10-17 Iain Sandoe <iains@gcc.gnu.org> + + * objc-act.c: Rename 'objc_public_flag' to objc_ivar_visibility and + make its type 'objc_ivar_visibility_kind'. + (objc_start_class_interface): Update to use visibility enum. + (objc_start_class_implementation): Likewise. + (objc_set_visibility): Update to use visibility enum, warn that + @package is handle as per @public. + (add_instance_variable): Handle OBJC_IVAR_VIS_PACKAGE. + * objc-act.h: Rename 'objc_public_flag' to objc_ivar_visibility and + make its type 'objc_ivar_visibility_kind'. + 2010-10-14 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 88f5d6c5a48..1be52d91b5c 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -150,7 +150,7 @@ static void objc_start_function (tree, tree, tree, struct c_arg_info *); static tree start_protocol (enum tree_code, tree, tree); static tree build_method_decl (enum tree_code, tree, tree, tree, bool); static tree objc_add_method (tree, tree, int, bool); -static tree add_instance_variable (tree, int, tree); +static tree add_instance_variable (tree, objc_ivar_visibility_kind, tree); static tree build_ivar_reference (tree); static tree is_ivar (tree, tree); @@ -385,7 +385,7 @@ int imp_count = 0; /* `@implementation' */ int cat_count = 0; /* `@category' */ enum tree_code objc_inherit_code; -int objc_public_flag; +objc_ivar_visibility_kind objc_ivar_visibility; /* Use to generate method labels. */ static int method_slot = 0; @@ -734,7 +734,7 @@ objc_start_class_interface (tree klass, tree super_class, objc_interface_context = objc_ivar_context = start_class (CLASS_INTERFACE_TYPE, klass, super_class, protos); - objc_public_flag = 0; + objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED; } void @@ -784,7 +784,7 @@ objc_start_class_implementation (tree klass, tree super_class) objc_implementation_context = objc_ivar_context = start_class (CLASS_IMPLEMENTATION_TYPE, klass, super_class, NULL_TREE); - objc_public_flag = 0; + objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED; } void @@ -822,9 +822,11 @@ objc_finish_implementation (void) } void -objc_set_visibility (int visibility) +objc_set_visibility (objc_ivar_visibility_kind visibility) { - objc_public_flag = visibility; + if (visibility == OBJC_IVAR_VIS_PACKAGE) + warning (0, "%<@package%> presently has the same effect as %<@public%>"); + objc_ivar_visibility = visibility; } void @@ -1352,7 +1354,7 @@ void objc_add_instance_variable (tree decl) { (void) add_instance_variable (objc_ivar_context, - objc_public_flag, + objc_ivar_visibility, decl); } @@ -2592,7 +2594,7 @@ string_eq (const void *ptr1, const void *ptr2) tree objc_build_string_object (tree string) { - tree constructor, constant_string_class; + tree constructor = NULL_TREE, constant_string_class; int length; tree fields, addr; struct string_descriptor *desc, key; @@ -7795,7 +7797,8 @@ add_category (tree klass, tree category) VISIBILITY is 1 for public, 0 for protected, and 2 for private. */ static tree -add_instance_variable (tree klass, int visibility, tree field_decl) +add_instance_variable (tree klass, objc_ivar_visibility_kind visibility, + tree field_decl) { tree field_type = TREE_TYPE (field_decl); const char *ivar_name = DECL_NAME (field_decl) @@ -7887,19 +7890,21 @@ add_instance_variable (tree klass, int visibility, tree field_decl) /* Overload the public attribute, it is not used for FIELD_DECLs. */ switch (visibility) { - case 0: + case OBJC_IVAR_VIS_PROTECTED: TREE_PUBLIC (field_decl) = 0; TREE_PRIVATE (field_decl) = 0; TREE_PROTECTED (field_decl) = 1; break; - case 1: + case OBJC_IVAR_VIS_PACKAGE: + /* TODO: Implement the package variant. */ + case OBJC_IVAR_VIS_PUBLIC: TREE_PUBLIC (field_decl) = 1; TREE_PRIVATE (field_decl) = 0; TREE_PROTECTED (field_decl) = 0; break; - case 2: + case OBJC_IVAR_VIS_PRIVATE: TREE_PUBLIC (field_decl) = 0; TREE_PRIVATE (field_decl) = 1; TREE_PROTECTED (field_decl) = 0; @@ -8520,7 +8525,7 @@ objc_gen_one_property_datum (tree klass, tree property, tree class_methods, bool objc_build_property_ivar_name (property)); DECL_CONTEXT (field_decl) = record; (void) add_instance_variable (klass, - 1, field_decl); + OBJC_IVAR_VIS_PUBLIC, field_decl); /* Unfortunately, CLASS_IVARS is completed when interface is completed. Must add the new ivar by hand to its list here. */ diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 1dd777c912f..a11a6de3ccc 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -175,7 +175,7 @@ extern GTY(()) int imp_count; /* `@implementation' */ extern GTY(()) int cat_count; /* `@category' */ extern GTY(()) enum tree_code objc_inherit_code; -extern GTY(()) int objc_public_flag; +extern GTY(()) objc_ivar_visibility_kind objc_ivar_visibility; /* Objective-C/Objective-C++ global tree enumeration. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b236d209d58..d678a0a5cd5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-10-17 Iain Sandoe <iains@gcc.gnu.org> + + * objc.dg/fsf-package-0.m: New. + * obj-c++.dg/fsf-package-0.m: New. + 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/18255 diff --git a/gcc/testsuite/obj-c++.dg/fsf-package-0.m b/gcc/testsuite/obj-c++.dg/fsf-package-0.m new file mode 100644 index 00000000000..d6b4db21777 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/fsf-package-0.m @@ -0,0 +1,37 @@ +/* { dg-do compile } */ + +#import "../objc-obj-c++-shared/Object1.h" +#include <objc/objc-api.h> + +@interface obj : Object +{ +@public + int v1; +@package /* { dg-warning ".@package. presently has the same effect as .@public." } */ + int v2; +@protected + int v3; +@private + int v4; +} +- (int) value; +- (void) setValue: (int)number; +@end + +@implementation obj : Object + +- (int) value { return v1; } +- (void) setValue: (int)number { v1 = number; } + +@end + +void foo (void) +{ + obj *a; + + [a setValue:2]; + a->v2 = 1; + a->v3 = [a value] - a->v2; /* { dg-warning ".v3. is @protected" } */ + a->v4 = a->v3 - 1; /* { dg-warning ".v4. is @private" } */ + /* { dg-warning ".v3. is @protected" "" { target *-*-* } 35 } */ +} diff --git a/gcc/testsuite/objc.dg/fsf-package-0.m b/gcc/testsuite/objc.dg/fsf-package-0.m new file mode 100644 index 00000000000..d6b4db21777 --- /dev/null +++ b/gcc/testsuite/objc.dg/fsf-package-0.m @@ -0,0 +1,37 @@ +/* { dg-do compile } */ + +#import "../objc-obj-c++-shared/Object1.h" +#include <objc/objc-api.h> + +@interface obj : Object +{ +@public + int v1; +@package /* { dg-warning ".@package. presently has the same effect as .@public." } */ + int v2; +@protected + int v3; +@private + int v4; +} +- (int) value; +- (void) setValue: (int)number; +@end + +@implementation obj : Object + +- (int) value { return v1; } +- (void) setValue: (int)number { v1 = number; } + +@end + +void foo (void) +{ + obj *a; + + [a setValue:2]; + a->v2 = 1; + a->v3 = [a value] - a->v2; /* { dg-warning ".v3. is @protected" } */ + a->v4 = a->v3 - 1; /* { dg-warning ".v4. is @private" } */ + /* { dg-warning ".v3. is @protected" "" { target *-*-* } 35 } */ +} |