diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-21 18:51:34 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-21 18:51:34 +0000 |
commit | e93ea189f714f1c8399f57d96a79fe2672807954 (patch) | |
tree | 897f0bbb69ee50c5f581e4a8d83c36076bdc3738 /gcc/objcp | |
parent | 2593b7b8135db4d43d62af403237e80b59ea9c9a (diff) | |
download | gcc-e93ea189f714f1c8399f57d96a79fe2672807954.tar.gz |
PR objc/25965
In gcc/objc/:
* objc-act.c (objc_get_interface_ivars): New function.
(objc_collecting_ivars): New variable.
(continue_class): Set and reset objc_collecting_ivars for context.
In gcc/:
* c-decl.c (detect_field_duplicates): If compiling Objective-C,
call objc_get_interface_ivars ().
* c-family/c-common.h (objc_get_interface_ivars): New declaration.
* c-family/stub-objc.c (objc_get_interface_ivars): New stub.
In gcc/objcp/:
* objcp-decl.c (objcp_finish_struct): Call
objc_get_interface_ivars() and check for duplicate ivars.
In gcc/testsuite/:
Merge from 'apple/trunk' branch on FSF servers.
2005-10-11 Fariborz Jahanian <fjahanian@apple.com>
Radar 4291785
objc.dg/naming-4.m: New
objc.dg/naming-5.m: New
obj-c++.dg/naming-1.mm: New
obj-c++.dg/naming-2.mm: New
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164491 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/objcp')
-rw-r--r-- | gcc/objcp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/objcp/objcp-decl.c | 34 |
2 files changed, 40 insertions, 0 deletions
diff --git a/gcc/objcp/ChangeLog b/gcc/objcp/ChangeLog index 109d2327ed6..e7fe12bcf0b 100644 --- a/gcc/objcp/ChangeLog +++ b/gcc/objcp/ChangeLog @@ -1,3 +1,9 @@ +2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com> + + PR objc/25965 + * objcp-decl.c (objcp_finish_struct): Call + objc_get_interface_ivars() and check for duplicate ivars. + 2010-06-28 Steven Bosscher <steven@gcc.gnu.org> * objcp-lang.c: Do not include except.h. diff --git a/gcc/objcp/objcp-decl.c b/gcc/objcp/objcp-decl.c index 8c688761098..af19a053823 100644 --- a/gcc/objcp/objcp-decl.c +++ b/gcc/objcp/objcp-decl.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "tree.h" #include "cp-tree.h" +#include "hashtab.h" #include "objc-act.h" #include "objcp-decl.h" @@ -63,6 +64,39 @@ objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED, finish_member_declaration (field); } t = finish_struct (t, attributes); + + /* If we are inside an @interface and are generating the list of + ivars, we need to check for duplicate ivars. + */ + if (fieldlist) + { + tree original_fieldlist = fieldlist; + fieldlist = objc_get_interface_ivars (fieldlist); + if (fieldlist != original_fieldlist) + { + /* Minimal implementation of the equivalent of the C + front-end's detect_field_duplicates(). + */ + htab_t htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL); + tree x, y; + void **slot; + + for (x = fieldlist; x ; x = DECL_CHAIN (x)) + if ((y = DECL_NAME (x)) != 0) + { + slot = htab_find_slot (htab, y, INSERT); + if (*slot) + { + error ("duplicate member %q+D", x); + DECL_NAME (x) = NULL_TREE; + } + *slot = y; + } + + htab_delete (htab); + } + } + pop_lang_context (); return t; |