aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjC
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaObjC')
-rw-r--r--test/SemaObjC/method-unused-attribute.m15
-rw-r--r--test/SemaObjC/property-category-2.m5
-rw-r--r--test/SemaObjC/property-category-impl.m31
-rw-r--r--test/SemaObjC/property-user-setter.m15
-rw-r--r--test/SemaObjC/property.m5
-rw-r--r--test/SemaObjC/super.m7
-rw-r--r--test/SemaObjC/unimplemented-protocol-prop.m20
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 000000000000..a4e53210c251
--- /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 f258b2c25012..e63672bb0ad7 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 000000000000..997949778c6e
--- /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 c06f2b6f44fb..babccee4a7f0 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 bc2056c97911..b7f0fcaa7629 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 3b8697288a3a..a61d72fda5ac 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 000000000000..d3de50efea58
--- /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}}