diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-09-21 18:51:34 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-09-21 18:51:34 +0000 |
commit | c0c24aa47091e72b753c922c01f071a72e531eee (patch) | |
tree | 897f0bbb69ee50c5f581e4a8d83c36076bdc3738 /gcc/objcp/objcp-decl.c | |
parent | f997b875dd00aaa75f85bbefa2e90ebfba7b6808 (diff) | |
download | gcc-c0c24aa47091e72b753c922c01f071a72e531eee.zip gcc-c0c24aa47091e72b753c922c01f071a72e531eee.tar.gz gcc-c0c24aa47091e72b753c922c01f071a72e531eee.tar.bz2 |
re PR objc/25965 (Allows duplicate member names in objc subclasses)
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
From-SVN: r164491
Diffstat (limited to 'gcc/objcp/objcp-decl.c')
-rw-r--r-- | gcc/objcp/objcp-decl.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/objcp/objcp-decl.c b/gcc/objcp/objcp-decl.c index 8c68876..af19a05 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; |