===================================================================
@@ -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. */
===================================================================
@@ -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>
===================================================================
@@ -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
===================================================================
@@ -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;
+ }
+};