Patchwork ObjC++ - another small bugfix - do not confuse template names with ObjC class names

login
register
mail settings
Submitter Nicola Pero
Date Oct. 18, 2010, 6:54 p.m.
Message ID <1287428054.618410781@192.168.2.230>
Download mbox | patch
Permalink /patch/68230/
State New
Headers show

Comments

Nicola Pero - Oct. 18, 2010, 6:54 p.m.
Merging yet another bugfix from the FSF apple/trunk branch.
Preapproved by Mike, committed to trunk.

Thanks

Patch

Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 165655)
+++ gcc/objc/objc-act.c (working copy)
@@ -3652,7 +3652,12 @@  objc_is_class_name (tree ident)
     ident = OBJC_TYPE_NAME (ident);
 #ifdef OBJCPLUS
   if (ident && TREE_CODE (ident) == TYPE_DECL)
-    ident = DECL_NAME (ident);
+    {
+      tree type = TREE_TYPE (ident);
+      if (type && TREE_CODE (type) == TEMPLATE_TYPE_PARM)
+        return NULL_TREE;
+      ident = DECL_NAME (ident);
+    }
 #endif
   if (!ident || TREE_CODE (ident) != IDENTIFIER_NODE)
     return NULL_TREE;
@@ -5236,6 +5241,10 @@  objc_generate_cxx_cdtors (void)
   bool need_ctor = false, need_dtor = false;
   tree ivar;
 
+  /* Error case, due to possibly an extra @end. */
+  if (!objc_implementation_context)
+    return;
+
   /* We do not want to do this for categories, since they do not have
      their own ivars.  */
 
Index: gcc/objc/ChangeLog
===================================================================
--- gcc/objc/ChangeLog  (revision 165655)
+++ gcc/objc/ChangeLog  (working copy)
@@ -1,6 +1,18 @@ 
 2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        Merge from 'apple/trunk' branch on FSF servers.
+
+       2006-03-10  Fariborz Jahanian <fjahanian@apple.com>
+
+        Radar 4407151
+       * objc/objc-act.c (objc_is_class_name): template parameter is not
+        an objective class name.
+        (objc_generate_cxx_cdtors): Check for the null
+        objc_implementation_context.   
+
+2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       Merge from 'apple/trunk' branch on FSF servers. 
        
        2005-11-08  Fariborz Jahanian <fjahanian@apple.com>
 
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog     (revision 165656)
+++ gcc/testsuite/ChangeLog     (working copy)
@@ -1,5 +1,14 @@ 
 2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>
+       
+       Merge from 'apple/trunk' branch on FSF servers.
 
+       2006-01-17  Fariborz Jahanian <fjahanian@apple.com>
+
+       Radar 4407151
+       * obj-c++.dg/template-7.mm: New.
+       
+2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        * objc.dg/proto-qual-1.m: Adjust test for GNU runtime to match
        bugfix.
 Index: gcc/testsuite/obj-c++.dg/template-7.mm
===================================================================
--- gcc/testsuite/obj-c++.dg/template-7.mm      (revision 0)
+++ gcc/testsuite/obj-c++.dg/template-7.mm      (revision 0)
@@ -0,0 +1,21 @@ 
+// Test that objective-c++ does not confuse a template parameter named 'Object'
+// with an interface of the same name.
+// Author: Fariborz Jahanian <fjahanian@apple.com>
+// { dg-do compile }
+// { dg-options "" }
+typedef struct objc_class *Class;
+
+@interface Object
+{
+ Class isa;
+}
+@end
+
+template <class Object>
+struct pyobject_type
+{ 
+    static Object* checked_downcast(Object* x)
+    {
+        return x;
+    }
+};