diff options
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; |