OSDN Git Service

2002-08-20 Devang Patel <dpatel@apple.com>
authordpatel <dpatel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2002 01:01:14 +0000 (01:01 +0000)
committerdpatel <dpatel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2002 01:01:14 +0000 (01:01 +0000)
        * tree.c (get_qualified_type): Add TYPE_CONTEXT check.

testsuite:
* objc.dg/proto-hier-2.m: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56475 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/proto-hier-2.m [new file with mode: 0644]
gcc/tree.c

index 62df30a..00e4f42 100644 (file)
@@ -1,3 +1,6 @@
+2002-08-20  Devang Patel  <dpatel@apple.com>
+       * tree.c (get_qualified_type): Add TYPE_CONTEXT check.
+       
 2002-08-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * arc.c (output_shift): Use stdio instead of asm_fprintf.
index 775dcb0..b682ab1 100644 (file)
@@ -1,3 +1,6 @@
+2002-08-20  Devang Patel  <dpatel@apple.com>
+       * objc.dg/proto-hier-2.m: New test.
+       
 2002-08-19  Ziemowit Laski  <zlaski@apple.com>
 
        * objc.dg/bitfield-1.m: New test.
diff --git a/gcc/testsuite/objc.dg/proto-hier-2.m b/gcc/testsuite/objc.dg/proto-hier-2.m
new file mode 100644 (file)
index 0000000..453de89
--- /dev/null
@@ -0,0 +1,49 @@
+/* Test protocol warning.  */
+/* Contributed by Devang Patel <dpatel@apple.com>.  */
+/* { dg-do compile } */
+
+typedef struct objc_object { struct objc_class *class_pointer; } *id;
+
+@protocol Bar
+@end
+
+id <Bar> Foo_Bar () { }
+
+typedef struct
+{
+        int i;
+} MyStruct;
+
+@interface Foo
+{
+  id _mainData;
+  MyStruct *_anotherData;
+}
+
+-(id) mainDataSource;
+-(id) anotherDataSource;
+-(id) my_method: (int) i;
+@end
+
+@implementation Foo
+-(id) anotherDataSource
+{
+        return (id)_anotherData;
+}
+
+-(id) mainDataSource
+{
+        return _mainData;
+}
+
+-(id) my_method: (int) i
+{
+  id one = [self anotherDataSource];
+
+  i = i - 1;
+  // Do not issue warning about my_method not implemented by protocol
+  return [(one ? [self mainDataSource] : one) my_method:i];
+}
+
+@end
+
index 9e725db..2c56b95 100644 (file)
@@ -2832,7 +2832,8 @@ get_qualified_type (type, type_quals)
      like the one we need to have.  If so, use that existing one.  We must
      preserve the TYPE_NAME, since there is code that depends on this.  */
   for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
-    if (TYPE_QUALS (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type))
+    if (TYPE_QUALS (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type)
+        && TYPE_CONTEXT (t) == TYPE_CONTEXT (type))
       return t;
 
   return NULL_TREE;