Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / testsuite / objc.dg / proto-lossage-1.m
blob2f7eb9861400dd2d08f18044f0735d39096828a8
1 /* Test for situations in which protocol conformance information
2    may be lost, leading to superfluous warnings.  */
3 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-do compile } */
6 /* One-line substitute for objc/objc.h */
7 typedef struct objc_object { struct objc_class *class_pointer; } *id;
9 @protocol NSObject
10 - (int)someValue;
11 @end
13 @interface NSObject <NSObject>
14 @end
16 @protocol PlateMethods
17 - (void)someMethod;
18 @end
20 @interface Foo {
21   NSObject <PlateMethods> *plate;
22   id <PlateMethods> plate1;
23   NSObject *plate2;
25 - (id <PlateMethods>) getPlate;
26 - (id <NSObject>) getPlate1;
27 - (int) getValue;
28 @end
30 @implementation Foo
31 - (id <PlateMethods>) getPlate {
32   return plate;  /* { dg-bogus "does not implement" } */
34 - (id <NSObject>) getPlate1 {
35   return (id <NSObject>)plate1; /* { dg-bogus "does not conform" } */
37 - (int) getValue {
38   int i = [plate1 someValue];   /* { dg-warning ".\\-someValue. not found in protocol\\(s\\)" } */
40   int j = [(id <NSObject>)plate1 someValue];  /* { dg-bogus "not found in protocol" } */
41   int k = [(id)plate1 someValue]; /* { dg-bogus "not found in protocol" } */
42   return i + j + k;
44 @end