diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
commit | 2fce988e86bc01829142e4362d4eff1af0925147 (patch) | |
tree | c69d3f4f13d508570bb5257a6aea735f88bdf09c /test/SemaObjC | |
parent | a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824 (diff) | |
download | FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.zip FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.tar.gz |
Update clang to r94309.
Diffstat (limited to 'test/SemaObjC')
-rw-r--r-- | test/SemaObjC/method-unused-attribute.m | 15 | ||||
-rw-r--r-- | test/SemaObjC/property-category-2.m | 5 | ||||
-rw-r--r-- | test/SemaObjC/property-category-impl.m | 31 | ||||
-rw-r--r-- | test/SemaObjC/property-user-setter.m | 15 | ||||
-rw-r--r-- | test/SemaObjC/property.m | 5 | ||||
-rw-r--r-- | test/SemaObjC/super.m | 7 | ||||
-rw-r--r-- | test/SemaObjC/unimplemented-protocol-prop.m | 20 |
7 files changed, 93 insertions, 5 deletions
diff --git a/test/SemaObjC/method-unused-attribute.m b/test/SemaObjC/method-unused-attribute.m new file mode 100644 index 0000000..a4e5321 --- /dev/null +++ b/test/SemaObjC/method-unused-attribute.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s + +@interface INTF +- (void) correct_use_of_unused: (void *) notice : (id)another_arg; +- (void) will_warn_unused_arg: (void *) notice : (id)warn_unused; +- (void) unused_attr_on_decl_ignored: (void *) __attribute__((unused)) will_warn; +@end + +@implementation INTF +- (void) correct_use_of_unused: (void *) __attribute__((unused)) notice : (id) __attribute__((unused)) newarg{ +} +- (void) will_warn_unused_arg: (void *) __attribute__((unused)) notice : (id)warn_unused {} // expected-warning {{unused parameter 'warn_unused'}} +- (void) unused_attr_on_decl_ignored: (void *) will_warn{} // expected-warning {{unused parameter 'will_warn'}} +@end + diff --git a/test/SemaObjC/property-category-2.m b/test/SemaObjC/property-category-2.m index f258b2c..e63672b 100644 --- a/test/SemaObjC/property-category-2.m +++ b/test/SemaObjC/property-category-2.m @@ -4,7 +4,8 @@ @protocol MyProtocol @property float myFloat; -@property float anotherFloat; +@property float anotherFloat; // expected-warning {{property 'anotherFloat' requires method 'anotherFloat' to be defined - use @dynamic}} \ + // expected-warning {{property 'anotherFloat' requires method 'setAnotherFloat:' to be defined }} @end @interface MyObject { float anotherFloat; } @@ -13,7 +14,7 @@ @interface MyObject (CAT) <MyProtocol> @end -@implementation MyObject (CAT) +@implementation MyObject (CAT) // expected-note 2 {{implementation is here}} @dynamic myFloat; // OK @synthesize anotherFloat; // expected-error {{@synthesize not allowed in a category's implementation}} @end diff --git a/test/SemaObjC/property-category-impl.m b/test/SemaObjC/property-category-impl.m new file mode 100644 index 0000000..9979497 --- /dev/null +++ b/test/SemaObjC/property-category-impl.m @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +/* This test is for categories which don't implement the accessors but some accessors are + implemented in their base class implementation. In this case,no warning must be issued. +*/ + +@interface MyClass +{ + int _foo; +} +@property(readonly) int foo; +@end + +@implementation MyClass +- (int) foo { return _foo; } +@end + +@interface MyClass (private) +@property(readwrite) int foo; +@end + +@implementation MyClass (private) +- (void) setFoo:(int)foo { _foo = foo; } +@end + +@interface MyClass (public) +@property(readwrite) int foo; // expected-warning {{property 'foo' requires method 'setFoo:' to be defined }} +@end + +@implementation MyClass (public)// expected-note {{implementation is here}} +@end diff --git a/test/SemaObjC/property-user-setter.m b/test/SemaObjC/property-user-setter.m index c06f2b6..babccee 100644 --- a/test/SemaObjC/property-user-setter.m +++ b/test/SemaObjC/property-user-setter.m @@ -80,11 +80,24 @@ static int g_val; } @end +@interface C {} +// - (int)Foo; +- (void)setFoo:(int)value; +@end + +void g(int); + +void f(C *c) { + c.Foo = 17; // expected-error {{property 'Foo' not found on object of type 'C *'}} + g(c.Foo); // expected-error {{property 'Foo' not found on object of type 'C *'}} +} + + void abort(void); int main (void) { Subclass *x = [[Subclass alloc] init]; - x.setterOnly = 4; + x.setterOnly = 4; // expected-error {{property 'setterOnly' not found on object of type 'Subclass *'}} if (g_val != 4) abort (); return 0; diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m index bc2056c..b7f0fca 100644 --- a/test/SemaObjC/property.m +++ b/test/SemaObjC/property.m @@ -11,7 +11,8 @@ @end @interface I(CAT) -@property int d1; +@property int d1; // expected-warning {{property 'd1' requires method 'd1' to be defined }} \ + // expected-warning {{property 'd1' requires method 'setD1:' to be defined }} @end @implementation I @@ -22,7 +23,7 @@ @synthesize name; // OK! property with same name as an accessible ivar of same name @end -@implementation I(CAT) +@implementation I(CAT) // expected-note 2 {{implementation is here}} @synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}} @dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}} @end diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m index 3b86972..a61d72f 100644 --- a/test/SemaObjC/super.m +++ b/test/SemaObjC/super.m @@ -39,3 +39,10 @@ void f0(int super) { void f1(int puper) { [super m]; // expected-error{{use of undeclared identifier 'super'}} } + +// radar 7400691 +typedef Foo super; + +void test() { + [super cMethod]; +} diff --git a/test/SemaObjC/unimplemented-protocol-prop.m b/test/SemaObjC/unimplemented-protocol-prop.m new file mode 100644 index 0000000..d3de50e --- /dev/null +++ b/test/SemaObjC/unimplemented-protocol-prop.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@protocol PROTOCOL0 +@required +@property float MyProperty0; // expected-warning {{property 'MyProperty0' requires method 'MyProperty0' to be defined }} \ + // expected-warning {{property 'MyProperty0' requires method 'setMyProperty0:' to be defined}} +@end + +@protocol PROTOCOL<PROTOCOL0> +@required +@property float MyProperty; // expected-warning {{property 'MyProperty' requires method 'MyProperty' to be defined}} \ + // expected-warning {{property 'MyProperty' requires method 'setMyProperty:' to be defined}} +@optional +@property float OptMyProperty; +@end + +@interface I <PROTOCOL> +@end + +@implementation I @end // expected-note 4 {{implementation is here}} |