Commit 3fecf49c by Ziemowit Laski Committed by Stan Shebs

fwd-proto-1.m: New.

2001-08-01  Ziemowit Laski  <zlaski@apple.com>

	* objc.dg/fwd-proto-1.m: New.
	* objc.dg/local-decl-1.m: New.
	* objc.dg/naming-1.m: New.
	* objc.dg/naming-2.m: New.
	* objc.dg/proto-hier-1.m: New.

From-SVN: r44537
parent f2e6e530
2001-08-01 Ziemowit Laski <zlaski@apple.com>
* objc.dg/fwd-proto-1.m: New.
* objc.dg/local-decl-1.m: New.
* objc.dg/naming-1.m: New.
* objc.dg/naming-2.m: New.
* objc.dg/proto-hier-1.m: New.
2001-07-31 Hans-Peter Nilsson <hp@bitrange.com>
* gcc.dg/c99-scope-2.c: Don't generally assume adding more
......
/* Test forward-decls for @protocols. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
/* One-line substitute for objc/objc.h */
typedef struct objc_object { struct objc_class *class_pointer; } *id;
@protocol Bar;
@protocol Boo;
@protocol Foo
- (id <Bar>)someMethod;
- (id <Baz>)anotherMethod; /* { dg-error "Cannot find protocol declaration" } */
@end
@protocol Bar <Boo>
- (id <Foo>)someOtherMethod;
- (id <Baz>)anotherMethod; /* { dg-error "Cannot find protocol declaration" } */
- (id <Boo>)yetAnotherMethod;
@end
/* The following worthy test is stubbed out until we can get the
harness to match correctly on the "compilation terminated" message
when running on GNU/Linux. sts 2001-08-01 */
#if 0
@protocol Boo <Bar> /* { /*dg*/-error "has circular dependency" } */
@end
#endif
/* Test for hiding of ivars by local variables. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
@interface Sprite {
int a;
}
@end
Sprite *glob;
@interface blah
{
Sprite* sprite;
}
@end
@implementation blah
- (Sprite *)load
{
Sprite *sprite = 0;
Sprite *glob = 0; /* ok */
return sprite; /* { dg-warning "hides instance variable" } */
}
@end
/* Test for obscuring of @interfaces with local vars. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
@interface View
@end
void foo(void)
{
int View; /* ok */
View = 1; /* ok */
View *view; /* { dg-error "`view' undeclared" } */
/* { dg-error "is reported only once" "" { target *-*-* } 12 } */
/* { dg-error "function it appears in" "" { target *-*-* } 12 } */
}
void bar(void)
{
View *view; /* ok */
View = 1; /* { dg-error "parse error" } */
}
/* Test for collision of @interfaces with global vars. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
@interface Foo
@end
float Foo; /* { dg-error "parse error before" } */
double Bar;
@interface Bar
@end /* { dg-error "redeclared as different kind of symbol" } */
/* { dg-error "previous declaration of" "" { target *-*-* } 9 } */
/* Test for handling of protocol hierarchies. */
/* Author: Ziemowit Laski <zlaski@apple.com>. */
/* { dg-do compile } */
/* One-line substitute for objc/objc.h */
typedef struct objc_object { struct objc_class *class_pointer; } *id;
@protocol NSObj
- (void)someMethod;
@end
@protocol NSCopying
- (void)someOtherMethod;
@end
@interface NSObject <NSObj>
- (void)someMethod;
@end
@implementation NSObject
- (void)someMethod {}
@end
@protocol Booing <NSObj>
- (void)boo;
@end
@interface Boo: NSObject <Booing> // protocol has only one parent
@end
@implementation Boo
- (void)boo {}
@end
@protocol Fooing <NSCopying, NSObj> // Fooing has two parent protocols
- (void)foo;
@end
@interface Foo: NSObject <Fooing>
@end
@implementation Foo
- (void)foo {}
- (void)someOtherMethod {}
@end
int foo(void) {
id<Booing, Fooing> stupidVar;
[stupidVar boo];
[stupidVar foo];
[stupidVar anotherMsg]; /* { dg-warning "not implemented by protocol" } */
/* { dg-warning "return type defaults to id" "" { target *-*-* } 51 } */
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment