From e93ea189f714f1c8399f57d96a79fe2672807954 Mon Sep 17 00:00:00 2001
From: nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 21 Sep 2010 18:51:34 +0000
Subject: 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
---
 gcc/objcp/ChangeLog    |  6 ++++++
 gcc/objcp/objcp-decl.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

(limited to 'gcc/objcp')

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;
-- 
cgit v1.2.1