+2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR objc/25965
+ * 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.
+
2010-09-21 Kai Tietz <kai.tietz@onevision.com>
PR target/45694
tree x, y;
int timeout = 10;
+ /* If the struct is the list of instance variables of an Objective-C
+ class, then we need to add all the instance variables of
+ superclasses before checking for duplicates (since you can't have
+ an instance variable in a subclass with the same name as an
+ instance variable in a superclass). objc_get_interface_ivars()
+ leaves fieldlist unchanged if we are not in this case, so in that
+ case nothing changes compared to C.
+ */
+ if (c_dialect_objc ())
+ fieldlist = objc_get_interface_ivars (fieldlist);
+
/* First, see if there are more than "a few" fields.
This is trivially true if there are zero or one fields. */
if (!fieldlist)
extern tree objc_get_protocol_qualified_type (tree, tree);
extern tree objc_get_class_reference (tree);
extern tree objc_get_class_ivars (tree);
+extern tree objc_get_interface_ivars (tree);
extern void objc_start_class_interface (tree, tree, tree);
extern void objc_start_category_interface (tree, tree, tree);
extern void objc_start_protocol (tree, tree);
}
tree
+objc_get_interface_ivars (tree ARG_UNUSED (fieldlist))
+{
+ return 0;
+}
+
+tree
objc_get_protocol_qualified_type (tree ARG_UNUSED (name),
tree ARG_UNUSED (protos))
{
+2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ PR objc/25965
+ * objc-act.c (objc_get_interface_ivars): New function.
+ (objc_collecting_ivars): New variable.
+ (continue_class): Set and reset objc_collecting_ivars for context.
+
2010-09-15 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
/* Use to generate method labels. */
static int method_slot = 0;
+static int objc_collecting_ivars = 0;
+
#define BUFSIZE 1024
static char *errbuf; /* Buffer for error diagnostics */
return error_mark_node;
}
+/* Called when checking the variables in a struct. If we are not
+ doing the ivars list inside an @interface context, then returns
+ fieldlist unchanged. Else, returns the list of class ivars.
+*/
+tree
+objc_get_interface_ivars (tree fieldlist)
+{
+ if (!objc_collecting_ivars || !objc_interface_context
+ || TREE_CODE (objc_interface_context) != CLASS_INTERFACE_TYPE
+ || CLASS_SUPER_NAME (objc_interface_context) == NULL_TREE)
+ return fieldlist;
+
+ return get_class_ivars (objc_interface_context, true);
+}
+
/* Used by: build_private_template, continue_class,
and for @defs constructs. */
push_lang_context (lang_name_c);
#endif /* OBJCPLUS */
+ objc_collecting_ivars = 1;
build_private_template (klass);
+ objc_collecting_ivars = 0;
#ifdef OBJCPLUS
pop_lang_context ();
+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.
#include "tm.h"
#include "tree.h"
#include "cp-tree.h"
+#include "hashtab.h"
#include "objc-act.h"
#include "objcp-decl.h"
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;
+2010-09-21 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ 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
+
2010-09-21 Jonathan Wakely <redi@gcc.gnu.org>
Jack Howarth <howarth@bromo.med.uc.edu>
--- /dev/null
+/* Testing for detecting duplicate ivars. */
+/* { dg-do compile } */
+
+typedef struct S { int i; } NSDictionary;
+
+@interface A
+{
+ NSDictionary * _userInfo;
+}
+@end
+
+@interface B : A
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+
+@interface C : A
+@end
+
+@interface D : C
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+
--- /dev/null
+/* Testing for detecting duplicate ivars. */
+/* { dg-do compile } */
+
+typedef struct S { int i; } NSDictionary;
+
+@interface A
+{
+ NSDictionary * _userInfo;
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+ int i5;
+ int i6;
+ int i7;
+}
+@end
+
+@interface B : A
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+ int ii1;
+ int ii2;
+ int ii3;
+ int ii4;
+ int ii5;
+ int ii6;
+ int ii7;
+}
+@end
+
+@interface C : A
+@end
+
+@interface D : C
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+
--- /dev/null
+/* Testing for detecting duplicate ivars. */
+/* { dg-do compile } */
+
+typedef struct S { int i; } NSDictionary;
+
+@interface A
+{
+ NSDictionary * _userInfo;
+}
+@end
+
+@interface B : A
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+
+@interface C : A
+@end
+
+@interface D : C
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
--- /dev/null
+/* Testing for detecting duplicate ivars. */
+/* { dg-do compile } */
+
+typedef struct S { int i; } NSDictionary;
+
+@interface A
+{
+ NSDictionary * _userInfo;
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+ int i5;
+ int i6;
+ int i7;
+}
+@end
+
+@interface B : A
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+ int ii1;
+ int ii2;
+ int ii3;
+ int ii4;
+ int ii5;
+ int ii6;
+ int ii7;
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+
+@interface C : A
+@end
+
+@interface D : C
+{
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+ NSDictionary * _userInfo; /* { dg-error "duplicate member" } */
+}
+@end
+