aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjC
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaObjC')
-rw-r--r--test/SemaObjC/arc-bridged-cast.m4
-rw-r--r--test/SemaObjC/arc-cf.m20
-rw-r--r--test/SemaObjC/arc-decls.m21
-rw-r--r--test/SemaObjC/arc-jump-block.m2
-rw-r--r--test/SemaObjC/arc-no-runtime.m2
-rw-r--r--test/SemaObjC/arc-non-pod-memaccess.m12
-rw-r--r--test/SemaObjC/arc-nsconsumed-errors.m20
-rw-r--r--test/SemaObjC/arc-peformselector.m2
-rw-r--r--test/SemaObjC/arc-property-decl-attrs.m16
-rw-r--r--test/SemaObjC/arc-property-lifetime.m21
-rw-r--r--test/SemaObjC/arc-property.m2
-rw-r--r--test/SemaObjC/arc-retain-block-property.m30
-rw-r--r--test/SemaObjC/arc-setter-property-match.m35
-rw-r--r--test/SemaObjC/arc-system-header.m4
-rw-r--r--test/SemaObjC/arc-type-conversion.m2
-rw-r--r--test/SemaObjC/arc-unavailable-for-weakref.m2
-rw-r--r--test/SemaObjC/arc-unavailable-system-function.m13
-rw-r--r--test/SemaObjC/arc-unbridged-cast.m78
-rw-r--r--test/SemaObjC/arc-unsafe-assigns.m2
-rw-r--r--test/SemaObjC/arc-unsafe_unretained.m4
-rw-r--r--test/SemaObjC/arc.m89
-rw-r--r--test/SemaObjC/assign-rvalue-message.m4
-rw-r--r--test/SemaObjC/at-defs.m2
-rw-r--r--test/SemaObjC/atomoic-property-synnthesis-rules.m24
-rw-r--r--test/SemaObjC/attr-availability.m13
-rw-r--r--test/SemaObjC/attr-deprecated.m15
-rw-r--r--test/SemaObjC/attr-ns-bridged.m15
-rw-r--r--test/SemaObjC/bad-property-synthesis-crash.m23
-rw-r--r--test/SemaObjC/blocks.m12
-rw-r--r--test/SemaObjC/builtin_objc_assign_ivar.m6
-rw-r--r--test/SemaObjC/class-bitfield.m2
-rw-r--r--test/SemaObjC/class-protocol-method-match.m48
-rw-r--r--test/SemaObjC/class-unavail-warning.m20
-rw-r--r--test/SemaObjC/comptypes-10.m18
-rw-r--r--test/SemaObjC/comptypes-7.m2
-rw-r--r--test/SemaObjC/conflict-atomic-property.m10
-rw-r--r--test/SemaObjC/conflict-nonfragile-abi2.m2
-rw-r--r--test/SemaObjC/conflicting-ivar-test-1.m2
-rw-r--r--test/SemaObjC/continuation-class-property.m19
-rw-r--r--test/SemaObjC/crash-label.m11
-rw-r--r--test/SemaObjC/default-synthesize-1.m26
-rw-r--r--test/SemaObjC/default-synthesize-2.m116
-rw-r--r--test/SemaObjC/default-synthesize.m8
-rw-r--r--test/SemaObjC/deref-interface.m2
-rw-r--r--test/SemaObjC/direct-synthesized-ivar-access.m7
-rw-r--r--test/SemaObjC/duplicate-ivar-in-class-extension.m2
-rw-r--r--test/SemaObjC/enum-fixed-type.m27
-rw-r--r--test/SemaObjC/error-property-gc-attr.m2
-rw-r--r--test/SemaObjC/iboutletcollection-attr.m5
-rw-r--r--test/SemaObjC/id-isa-ref.m2
-rw-r--r--test/SemaObjC/incomplete-implementation.m9
-rw-r--r--test/SemaObjC/instancetype.m190
-rw-r--r--test/SemaObjC/interface-1.m2
-rw-r--r--test/SemaObjC/interface-layout.m2
-rw-r--r--test/SemaObjC/ivar-in-class-extension-error.m2
-rw-r--r--test/SemaObjC/ivar-in-class-extension.m2
-rw-r--r--test/SemaObjC/ivar-in-implementations.m2
-rw-r--r--test/SemaObjC/ivar-sem-check-2.m2
-rw-r--r--test/SemaObjC/method-no-context.m3
-rw-r--r--test/SemaObjC/missing-atend-metadata.m2
-rw-r--r--test/SemaObjC/missing-method-return-type.m11
-rw-r--r--test/SemaObjC/nested-typedef-decl.m21
-rw-r--r--test/SemaObjC/objc-buffered-methods.m25
-rw-r--r--test/SemaObjC/property-and-class-extension.m2
-rw-r--r--test/SemaObjC/property-and-ivar-use.m2
-rw-r--r--test/SemaObjC/property-category-1.m4
-rw-r--r--test/SemaObjC/property-category-2.m6
-rw-r--r--test/SemaObjC/property-category-3.m2
-rw-r--r--test/SemaObjC/property-category-impl.m4
-rw-r--r--test/SemaObjC/property-inherited.m4
-rw-r--r--test/SemaObjC/property-nonfragile-abi.m2
-rw-r--r--test/SemaObjC/property-ns-returns-not-retained-attr.m2
-rw-r--r--test/SemaObjC/property.m10
-rw-r--r--test/SemaObjC/protocol-archane.m7
-rw-r--r--test/SemaObjC/protocol-implementing-class-methods.m41
-rw-r--r--test/SemaObjC/provisional-ivar-lookup.m2
-rw-r--r--test/SemaObjC/qualified-protocol-method-conflicts.m39
-rw-r--r--test/SemaObjC/related-result-type-inference.m6
-rw-r--r--test/SemaObjC/return.m11
-rw-r--r--test/SemaObjC/self-declared-in-block.m4
-rw-r--r--test/SemaObjC/sizeof-interface.m2
-rw-r--r--test/SemaObjC/super-class-protocol-conformance.m12
-rw-r--r--test/SemaObjC/synth-provisional-ivars-1.m2
-rw-r--r--test/SemaObjC/synth-provisional-ivars.m12
-rw-r--r--test/SemaObjC/synthesized-ivar.m10
-rw-r--r--test/SemaObjC/undeclared-selector.m2
-rw-r--r--test/SemaObjC/unimplemented-protocol-prop.m29
-rw-r--r--test/SemaObjC/uninit-variables.m2
-rw-r--r--test/SemaObjC/warn-deprecated-implementations.m3
-rw-r--r--test/SemaObjC/warn-implicit-atomic-property.m2
-rw-r--r--test/SemaObjC/warn-missing-super.m57
-rw-r--r--test/SemaObjC/warn-retain-cycle.m4
-rw-r--r--test/SemaObjC/weak-property.m2
93 files changed, 1218 insertions, 168 deletions
diff --git a/test/SemaObjC/arc-bridged-cast.m b/test/SemaObjC/arc-bridged-cast.m
index e883406db908..47476c83064d 100644
--- a/test/SemaObjC/arc-bridged-cast.m
+++ b/test/SemaObjC/arc-bridged-cast.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -fblocks -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fblocks %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks %s
typedef const void *CFTypeRef;
typedef const struct __CFString *CFStringRef;
diff --git a/test/SemaObjC/arc-cf.m b/test/SemaObjC/arc-cf.m
new file mode 100644
index 000000000000..c1df3e0489f1
--- /dev/null
+++ b/test/SemaObjC/arc-cf.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+extern CFStringRef CFMakeString0(void);
+extern CFStringRef CFCreateString0(void);
+void test0() {
+ id x;
+ x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+}
+
+extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
+extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained));
+void test1() {
+ id x;
+ x = (id) CFMakeString1();
+ x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+}
diff --git a/test/SemaObjC/arc-decls.m b/test/SemaObjC/arc-decls.m
index e713d239a0cf..1084db86268f 100644
--- a/test/SemaObjC/arc-decls.m
+++ b/test/SemaObjC/arc-decls.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
// rdar://8843524
@@ -62,3 +62,22 @@ void func()
- new {return 0; };
@end
+
+// rdar://10187884
+@interface Super
+- (void)bar:(id)b; // expected-note {{parameter declared here}}
+- (void)bar1:(id) __attribute((ns_consumed)) b;
+- (void)ok:(id) __attribute((ns_consumed)) b;
+- (id)ns_non; // expected-note {{method declared here}}
+- (id)not_ret:(id) b __attribute((ns_returns_not_retained)); // expected-note {{method declared here}}
+- (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained));
+@end
+
+@interface Sub : Super
+- (void)bar:(id) __attribute((ns_consumed)) b; // expected-error {{overriding method has mismatched ns_consumed attribute on its parameter}}
+- (void)bar1:(id)b;
+- (void)ok:(id) __attribute((ns_consumed)) b;
+- (id)ns_non __attribute((ns_returns_not_retained)); // expected-error {{overriding method has mismatched ns_returns_not_retained attributes}}
+- (id)not_ret:(id) b __attribute((ns_returns_retained)); // expected-error {{overriding method has mismatched ns_returns_retained attributes}}
+- (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained));
+@end
diff --git a/test/SemaObjC/arc-jump-block.m b/test/SemaObjC/arc-jump-block.m
index 1c7b21e4e8cd..9b44606c59d3 100644
--- a/test/SemaObjC/arc-jump-block.m
+++ b/test/SemaObjC/arc-jump-block.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
// rdar://9535237
typedef struct dispatch_queue_s *dispatch_queue_t;
diff --git a/test/SemaObjC/arc-no-runtime.m b/test/SemaObjC/arc-no-runtime.m
index 94299e235e81..49c439b16760 100644
--- a/test/SemaObjC/arc-no-runtime.m
+++ b/test/SemaObjC/arc-no-runtime.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fobjc-arc -verify %s
// rdar://problem/9150784
void test(void) {
diff --git a/test/SemaObjC/arc-non-pod-memaccess.m b/test/SemaObjC/arc-non-pod-memaccess.m
index c9a77519694d..2b1223abbe78 100644
--- a/test/SemaObjC/arc-non-pod-memaccess.m
+++ b/test/SemaObjC/arc-non-pod-memaccess.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
-// RUN: %clang_cc1 -x objective-c++ -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
#ifdef __cplusplus
extern "C" {
@@ -53,3 +53,11 @@ void test(id __strong *sip, id __weak *wip, id __autoreleasing *aip,
// expected-note{{explicitly cast the pointer to silence this warning}}
memmove(ptr, uip, 17);
}
+
+void rdar9772982(int i, ...) {
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, i);
+ __builtin_va_arg(ap, __strong id); // expected-error{{second argument to 'va_arg' is of ARC ownership-qualified type '__strong id'}}
+ __builtin_va_end(ap);
+}
diff --git a/test/SemaObjC/arc-nsconsumed-errors.m b/test/SemaObjC/arc-nsconsumed-errors.m
new file mode 100644
index 000000000000..62e74aabaffd
--- /dev/null
+++ b/test/SemaObjC/arc-nsconsumed-errors.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// rdar://10187884
+
+typedef void (^blk)(id arg1, __attribute((ns_consumed)) id arg2);
+typedef void (^blk1)(__attribute((ns_consumed))id arg1, __attribute((ns_consumed)) id arg2);
+blk a = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk b = ^void (id arg1, __attribute((ns_consumed)) id arg2){};
+
+blk c = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk d = ^void (id arg1, id arg2) {}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 a1 = ^void (__attribute((ns_consumed)) id arg1, id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 b2 = ^void (id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 c3 = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){};
+
+blk1 d4 = ^void (id arg1, id arg2) {}; // expected-error {{incompatible block pointer types initializing}}
diff --git a/test/SemaObjC/arc-peformselector.m b/test/SemaObjC/arc-peformselector.m
index e637f3d76ff4..c015eb871150 100644
--- a/test/SemaObjC/arc-peformselector.m
+++ b/test/SemaObjC/arc-peformselector.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
// rdar://9659270
@interface NSObject
diff --git a/test/SemaObjC/arc-property-decl-attrs.m b/test/SemaObjC/arc-property-decl-attrs.m
index 0dd74b8ad5ce..1386241dd73c 100644
--- a/test/SemaObjC/arc-property-decl-attrs.m
+++ b/test/SemaObjC/arc-property-decl-attrs.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
// rdar://9340606
@interface Foo {
@@ -65,3 +65,17 @@
@property(unsafe_unretained) __weak id y; // expected-error {{property attributes 'unsafe_unretained' and 'weak' are mutually exclusive}}
@property(unsafe_unretained) __autoreleasing id z; // expected-error {{unsafe_unretained property 'z' may not also be declared __autoreleasing}}
@end
+
+// rdar://9396329
+@interface Super
+@property (readonly, retain) id foo;
+@property (readonly, weak) id fee;
+@property (readonly, strong) id frr;
+@end
+
+@interface Bugg : Super
+@property (readwrite) id foo;
+@property (readwrite) id fee;
+@property (readwrite) id frr;
+@end
+
diff --git a/test/SemaObjC/arc-property-lifetime.m b/test/SemaObjC/arc-property-lifetime.m
index b1c84c75c058..9cc3ada15fad 100644
--- a/test/SemaObjC/arc-property-lifetime.m
+++ b/test/SemaObjC/arc-property-lifetime.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
// rdar://9340606
@interface Foo {
@@ -79,7 +79,7 @@
@implementation Gorf
@synthesize x;
-@synthesize y; // expected-error {{existing ivar 'y' for unsafe_unretained property 'y' must be __unsafe_unretained}}
+@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with assign attribute must be __unsafe_unretained}}
@synthesize z;
@end
@@ -94,7 +94,7 @@
@implementation Gorf2
@synthesize x;
-@synthesize y; // expected-error {{existing ivar 'y' for unsafe_unretained property 'y' must be __unsafe_unretained}}
+@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with unsafe_unretained attribute must be __unsafe_unretained}}
@synthesize z;
@end
@@ -110,3 +110,18 @@
@synthesize isAutosaving = _isAutosaving;
@end
+// rdar://10239594
+// Test for 'Class' properties being unretained.
+@interface MyClass {
+@private
+ Class _controllerClass;
+ id _controllerId;
+}
+@property (copy) Class controllerClass;
+@property (copy) id controllerId;
+@end
+
+@implementation MyClass
+@synthesize controllerClass = _controllerClass;
+@synthesize controllerId = _controllerId;
+@end
diff --git a/test/SemaObjC/arc-property.m b/test/SemaObjC/arc-property.m
index 0651f1808dc9..299311859203 100644
--- a/test/SemaObjC/arc-property.m
+++ b/test/SemaObjC/arc-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
// rdar://9309489
@interface MyClass {
diff --git a/test/SemaObjC/arc-retain-block-property.m b/test/SemaObjC/arc-retain-block-property.m
new file mode 100644
index 000000000000..c7d043004948
--- /dev/null
+++ b/test/SemaObjC/arc-retain-block-property.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s
+// rdar://9829425
+
+extern void doSomething();
+
+@interface Test
+{
+@public
+ void (^aBlock)(void);
+}
+@property (retain) void (^aBlock)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
+@property (weak, retain) void (^aBlockW)(void); // expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}}
+@property (strong, retain) void (^aBlockS)(void); // OK
+@property (readonly, retain) void (^aBlockR)(void); // OK
+@property (copy, retain) void (^aBlockC)(void); // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+@property (assign, retain) void (^aBlockA)(void); // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@end
+
+@implementation Test
+@synthesize aBlock;
+@dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
+@end
+
+int main() {
+ Test *t;
+ t.aBlock = ^{ doSomething(); };
+ t.aBlockW = ^{ doSomething(); };
+ t.aBlockS = ^{ doSomething(); };
+}
+
diff --git a/test/SemaObjC/arc-setter-property-match.m b/test/SemaObjC/arc-setter-property-match.m
new file mode 100644
index 000000000000..0de0a11f1bbe
--- /dev/null
+++ b/test/SemaObjC/arc-setter-property-match.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// rdar://10156674
+
+@class NSArray;
+
+@interface MyClass2 {
+@private
+ NSArray *_names1;
+ NSArray *_names2;
+ NSArray *_names3;
+ NSArray *_names4;
+}
+@property (readwrite, strong) NSArray *names1; // <-- warning: Type of property....
+- (void)setNames1:(NSArray *)names;
+@property (readwrite, strong) __strong NSArray *names2; // <-- warning: Type of property....
+- (void)setNames2:(NSArray *)names;
+@property (readwrite, strong) __strong NSArray *names3; // <-- OK
+- (void)setNames3:(__strong NSArray *)names;
+@property (readwrite, strong) NSArray *names4; // <-- warning: Type of property....
+- (void)setNames4:(__strong NSArray *)names;
+
+@end
+
+@implementation MyClass2
+- (NSArray *)names1 { return _names1; }
+- (void)setNames1:(NSArray *)names {}
+- (NSArray *)names2 { return _names2; }
+- (void)setNames2:(NSArray *)names {}
+- (NSArray *)names3 { return _names3; }
+- (void)setNames3:(__strong NSArray *)names {}
+- (NSArray *)names4 { return _names4; }
+- (void)setNames4:(__strong NSArray *)names {}
+
+@end
+
diff --git a/test/SemaObjC/arc-system-header.m b/test/SemaObjC/arc-system-header.m
index 3f176577156f..1a7c39d4e1cd 100644
--- a/test/SemaObjC/arc-system-header.m
+++ b/test/SemaObjC/arc-system-header.m
@@ -1,6 +1,6 @@
// silly workaround expected-note {{marked unavailable here}}
-// RUN: %clang_cc1 -fobjc-arc -fobjc-nonfragile-abi -isystem %S/Inputs %s -DNO_USE
-// RUN: %clang_cc1 -fobjc-arc -fobjc-nonfragile-abi -isystem %S/Inputs %s -verify
+// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -DNO_USE
+// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
// another silly workaround expected-note {{marked unavailable here}}
#include <arc-system-header.h>
diff --git a/test/SemaObjC/arc-type-conversion.m b/test/SemaObjC/arc-type-conversion.m
index 103db5695f49..01f61bd4b674 100644
--- a/test/SemaObjC/arc-type-conversion.m
+++ b/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-nonfragile-abi -fobjc-runtime-has-weak -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
void * cvt(id arg)
{
diff --git a/test/SemaObjC/arc-unavailable-for-weakref.m b/test/SemaObjC/arc-unavailable-for-weakref.m
index 104314e6b1d3..6db2155f8c64 100644
--- a/test/SemaObjC/arc-unavailable-for-weakref.m
+++ b/test/SemaObjC/arc-unavailable-for-weakref.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
// rdar://9693477
__attribute__((objc_arc_weak_reference_unavailable))
diff --git a/test/SemaObjC/arc-unavailable-system-function.m b/test/SemaObjC/arc-unavailable-system-function.m
new file mode 100644
index 000000000000..b0b70db641cb
--- /dev/null
+++ b/test/SemaObjC/arc-unavailable-system-function.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin11 -fobjc-arc -verify %s
+// rdar://10186625
+
+# 1 "<command line>"
+# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3
+id * foo(); // expected-note {{function has been explicitly marked unavailable here}}
+
+# 1 "arc-unavailable-system-function.m" 2
+void ret() {
+ foo(); // expected-error {{'foo' is unavailable: this system declaration uses an unsupported type}}
+}
+
+
diff --git a/test/SemaObjC/arc-unbridged-cast.m b/test/SemaObjC/arc-unbridged-cast.m
index 03c84cfce336..8b835a14986d 100644
--- a/test/SemaObjC/arc-unbridged-cast.m
+++ b/test/SemaObjC/arc-unbridged-cast.m
@@ -1,18 +1,72 @@
-// // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -verify %s
-// rdar://9744349
+// // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
typedef const struct __CFString * CFStringRef;
-@interface I
-@property CFStringRef P;
+@interface Object
+@property CFStringRef property;
+- (CFStringRef) implicitProperty;
+- (CFStringRef) newString;
+- (CFStringRef) makeString;
@end
-@implementation I
-@synthesize P;
-- (id) Meth {
- I* p1 = (id)[p1 P];
- id p2 = (__bridge_transfer id)[p1 P];
- id p3 = (__bridge I*)[p1 P];
- return (id) p1.P;
+extern Object *object;
+
+// rdar://9744349
+id test0(void) {
+ id p1 = (id)[object property];
+ id p2 = (__bridge_transfer id)[object property];
+ id p3 = (__bridge id)[object property];
+ return (id) object.property;
+}
+
+// rdar://10140692
+CFStringRef unauditedString(void);
+CFStringRef plusOneString(void) __attribute__((cf_returns_retained));
+
+#pragma clang arc_cf_code_audited begin
+CFStringRef auditedString(void);
+CFStringRef auditedCreateString(void);
+#pragma clang arc_cf_code_audited end
+
+void test1(int cond) {
+ id x;
+ x = (id) auditedString();
+ x = (id) (cond ? auditedString() : (void*) 0);
+ x = (id) (cond ? (void*) 0 : auditedString());
+ x = (id) (cond ? (CFStringRef) @"help" : auditedString());
+
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+
+ x = (id) [object property];
+ x = (id) (cond ? [object property] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object property]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object property]);
+
+ x = (id) object.property;
+ x = (id) (cond ? object.property : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.property);
+ x = (id) (cond ? (CFStringRef) @"help" : object.property);
+
+ x = (id) object.implicitProperty;
+ x = (id) (cond ? object.implicitProperty : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.implicitProperty);
+ x = (id) (cond ? (CFStringRef) @"help" : object.implicitProperty);
+
+ x = (id) [object makeString];
+ x = (id) (cond ? [object makeString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object makeString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object makeString]);
+
+ x = (id) [object newString];
+ x = (id) (cond ? [object newString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object newString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object newString]); // a bit questionable
}
-@end
diff --git a/test/SemaObjC/arc-unsafe-assigns.m b/test/SemaObjC/arc-unsafe-assigns.m
index be8f90295e8b..6dba18ba073b 100644
--- a/test/SemaObjC/arc-unsafe-assigns.m
+++ b/test/SemaObjC/arc-unsafe-assigns.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
// rdar://9495837
@interface Foo {
diff --git a/test/SemaObjC/arc-unsafe_unretained.m b/test/SemaObjC/arc-unsafe_unretained.m
index 77bdded1763b..a6c5f985df8f 100644
--- a/test/SemaObjC/arc-unsafe_unretained.m
+++ b/test/SemaObjC/arc-unsafe_unretained.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -fobjc-nonfragile-abi %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fobjc-nonfragile-abi -fobjc-arc %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fobjc-arc %s
struct X {
__unsafe_unretained id object;
diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m
index 3d190e5c53a0..ed6e60d8dc2f 100644
--- a/test/SemaObjC/arc.m
+++ b/test/SemaObjC/arc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
typedef unsigned long NSUInteger;
@@ -41,10 +41,10 @@ __weak __strong id x; // expected-error {{the type '__strong id' already has ret
// rdar://8843638
@interface I
-- (id)retain;
-- (id)autorelease;
-- (oneway void)release;
-- (NSUInteger)retainCount;
+- (id)retain; // expected-note {{method declared here}}
+- (id)autorelease; // expected-note {{method declared here}}
+- (oneway void)release; // expected-note {{method declared here}}
+- (NSUInteger)retainCount; // expected-note {{method declared here}}
@end
@implementation I
@@ -55,10 +55,14 @@ __weak __strong id x; // expected-error {{the type '__strong id' already has ret
@end
@implementation I(CAT)
-- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}}
-- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}}
-- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}}
-- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}}
+- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
@end
// rdar://8861761
@@ -483,19 +487,29 @@ void test26(id y) {
@end
// rdar://9525555
-@interface Test27
-@property id x; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
- // expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} \
- // expected-note {{declared here}}
+@interface Test27 {
+ __weak id _myProp1;
+ id myProp2;
+}
+@property id x;
@property (readonly) id ro; // expected-note {{declared here}}
@property (readonly) id custom_ro;
@property int y;
+
+@property (readonly) id myProp1;
+@property (readonly) id myProp2;
+@property (readonly) __strong id myProp3;
@end
@implementation Test27
-@synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}}
-@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}}
+@synthesize x;
+@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
@synthesize y;
+
+@synthesize myProp1 = _myProp1;
+@synthesize myProp2;
+@synthesize myProp3;
+
-(id)custom_ro { return 0; }
@end
@@ -626,3 +640,48 @@ void test36(int first, ...) {
id obj = __builtin_va_arg(arglist, id);
__builtin_va_end(arglist);
}
+
+@class Test37;
+void test37(Test37 *c) {
+ for (id y in c) { // expected-error {{collection expression type 'Test37' is a forward declaration}}
+ (void) y;
+ }
+
+ (void)sizeof(id*); // no error.
+}
+
+// rdar://problem/9887979
+@interface Test38
+@property int value;
+@end
+void test38() {
+ extern Test38 *test38_helper(void);
+ switch (test38_helper().value) {
+ case 0:
+ case 1:
+ ;
+ }
+}
+
+// rdar://10186536
+@class NSColor;
+void _NSCalc(NSColor* color, NSColor* bezelColors[]) __attribute__((unavailable("not available in automatic reference counting mode")));
+
+void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{must explicitly describe intended ownership of an object array parameter}}
+
+// rdar://9970739
+@interface RestaurantTableViewCell
+- (void) restaurantLocation;
+@end
+
+@interface Radar9970739
+- (void) Meth;
+@end
+
+@implementation Radar9970739
+- (void) Meth {
+ RestaurantTableViewCell *cell;
+ [cell restaurantLocatoin]; // expected-error {{no visible @interface for 'RestaurantTableViewCell' declares the selector 'restaurantLocatoin'}}
+}
+@end
+
diff --git a/test/SemaObjC/assign-rvalue-message.m b/test/SemaObjC/assign-rvalue-message.m
index 7e05c89afa43..8cbce8e2ee54 100644
--- a/test/SemaObjC/assign-rvalue-message.m
+++ b/test/SemaObjC/assign-rvalue-message.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fobjc-nonfragile-abi %s
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fobjc-nonfragile-abi %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
// rdar://9005189
@interface Foo
diff --git a/test/SemaObjC/at-defs.m b/test/SemaObjC/at-defs.m
index bfa212375050..4c0c586fe838 100644
--- a/test/SemaObjC/at-defs.m
+++ b/test/SemaObjC/at-defs.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown %s -fsyntax-only
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi %s -fsyntax-only
@interface Test {
double a;
diff --git a/test/SemaObjC/atomoic-property-synnthesis-rules.m b/test/SemaObjC/atomoic-property-synnthesis-rules.m
index af790e3159ad..2061a779dc57 100644
--- a/test/SemaObjC/atomoic-property-synnthesis-rules.m
+++ b/test/SemaObjC/atomoic-property-synnthesis-rules.m
@@ -240,8 +240,10 @@
GET(GetSet)
SET(GetSet)
-GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter/getter with a user defined setter/getter}}
-SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}} \
+ // expected-note {{setter and getter must both be synthesized}}
+SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}} \
+ // expected-note {{setter and getter must both be synthesized}}
GET(GetSet_Nonatomic)
SET(GetSet_Nonatomic)
GET(Get_Nonatomic)
@@ -258,8 +260,10 @@ SET(Set_Nonatomic_ReadOnly)
GET(GetSet_ReadWriteInExt)
SET(GetSet_ReadWriteInExt)
-GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}}
-SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}} \
+ // expected-note {{setter and getter must both be synthesized}}
+SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}} \
+ // expected-note {{setter and getter must both be synthesized}}
GET(GetSet_Nonatomic_ReadWriteInExt)
SET(GetSet_Nonatomic_ReadWriteInExt)
GET(Get_Nonatomic_ReadWriteInExt)
@@ -268,8 +272,10 @@ SET(Set_Nonatomic_ReadWriteInExt)
GET(GetSet_LateSynthesize)
SET(GetSet_LateSynthesize)
-GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
-SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \
+ // expected-note {{setter and getter must both be synthesized}}
+SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \
+ // expected-note {{setter and getter must both be synthesized}}
GET(GetSet_Nonatomic_LateSynthesize)
SET(GetSet_Nonatomic_LateSynthesize)
GET(Get_Nonatomic_LateSynthesize)
@@ -286,8 +292,10 @@ SET(Set_Nonatomic_ReadOnly_LateSynthesize)
GET(GetSet_ReadWriteInExt_LateSynthesize)
SET(GetSet_ReadWriteInExt_LateSynthesize)
-GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
-SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}}
+GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \
+ // expected-note {{setter and getter must both be synthesized}}
+SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \
+ // expected-note {{setter and getter must both be synthesized}}
GET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
SET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
GET(Get_Nonatomic_ReadWriteInExt_LateSynthesize)
diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m
new file mode 100644
index 000000000000..d857bda77234
--- /dev/null
+++ b/test/SemaObjC/attr-availability.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
+@interface A
+- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2)));
+@end
+
+@interface B : A
+- (void)method;
+@end
+
+void f(A *a, B *b) {
+ [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}}
+ [b method];
+}
diff --git a/test/SemaObjC/attr-deprecated.m b/test/SemaObjC/attr-deprecated.m
index d3d5f9537b73..ca267599288e 100644
--- a/test/SemaObjC/attr-deprecated.m
+++ b/test/SemaObjC/attr-deprecated.m
@@ -85,12 +85,21 @@ int t5() {
__attribute ((deprecated))
@interface DEPRECATED {
@public int ivar;
+ DEPRECATED *ivar2; // no warning.
}
- (int) instancemethod;
+- (DEPRECATED *) meth; // no warning.
@property int prop;
@end
-@interface DEPRECATED (Category) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
+@interface DEPRECATED (Category) // no warning.
+- (DEPRECATED *) meth2; // no warning.
+@end
+
+@interface DEPRECATED (Category2) // no warning.
+@end
+
+@implementation DEPRECATED (Category2) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
@end
@interface NS : DEPRECATED // expected-warning {{warning: 'DEPRECATED' is deprecated}}
@@ -108,3 +117,7 @@ void test(Test2 *foo) {
foo.test2 = x; // expected-warning {{'test2' is deprecated}}
[foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
}
+
+__attribute__((deprecated))
+@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
+@end
diff --git a/test/SemaObjC/attr-ns-bridged.m b/test/SemaObjC/attr-ns-bridged.m
new file mode 100644
index 000000000000..1ab60a2b0d80
--- /dev/null
+++ b/test/SemaObjC/attr-ns-bridged.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct __attribute__((ns_bridged)) test0s *test0ref;
+
+void test0func(void) __attribute__((ns_bridged)); // expected-error {{'ns_bridged' attribute only applies to structs}}
+
+union __attribute__((ns_bridged)) test0u; // expected-error {{'ns_bridged' attribute only applies to structs}}
+
+struct __attribute__((ns_bridged(Test1))) test1s;
+
+@class Test2;
+struct __attribute__((ns_bridged(Test2))) test2s;
+
+void Test3(void); // expected-note {{declared here}}
+struct __attribute__((ns_bridged(Test3))) test3s; // expected-error {{parameter of 'ns_bridged' attribute does not name an Objective-C class}}
diff --git a/test/SemaObjC/bad-property-synthesis-crash.m b/test/SemaObjC/bad-property-synthesis-crash.m
new file mode 100644
index 000000000000..577faea9dadc
--- /dev/null
+++ b/test/SemaObjC/bad-property-synthesis-crash.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10177744
+
+@interface Foo
+@property (nonatomic, retain) NSString* what; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{property with}} \
+ // expected-note {{previous definition is here}}
+@end
+
+@implementation Foo
+- (void) setWhat: (NSString*) value { // expected-error {{expected a type}} \
+ // expected-warning {{conflicting parameter types in implementation of}}
+ __what; // expected-error {{use of undeclared identifier}} \
+ // expected-warning {{expression result unused}}
+}
+@synthesize what; // expected-note 2 {{'what' declared here}}
+@end
+
+@implementation Bar // expected-warning {{cannot find interface declaration for}}
+- (NSString*) what { // expected-error {{expected a type}}
+ return __what; // expected-error {{use of undeclared identifier}}
+}
+@end
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 15aa5811cc53..2d77a20fce03 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+
+#define bool _Bool
@protocol NSObject;
void bar(id(^)(void));
@@ -21,9 +23,13 @@ void foo4(id (^objectCreationBlock)(int)) {
return bar4(objectCreationBlock);
}
-void bar5(id(^)(void)); // expected-note{{passing argument to parameter here}}
-void foo5(id (^objectCreationBlock)(int)) {
- return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)' to parameter of type 'id (^)(void)'}}
+void bar5(id(^)(void)); // expected-note 3{{passing argument to parameter here}}
+void foo5(id (^objectCreationBlock)(bool)) {
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(bool)' to parameter of type 'id (^)(void)'}}
+#undef bool
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
+#define bool int
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
}
void bar6(id(^)(int));
diff --git a/test/SemaObjC/builtin_objc_assign_ivar.m b/test/SemaObjC/builtin_objc_assign_ivar.m
new file mode 100644
index 000000000000..5839bf444419
--- /dev/null
+++ b/test/SemaObjC/builtin_objc_assign_ivar.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+// rdar://9362887
+
+typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
+extern id objc_assign_ivar(id value, id dest, ptrdiff_t offset);
+
diff --git a/test/SemaObjC/class-bitfield.m b/test/SemaObjC/class-bitfield.m
index c0393c2287c1..ae12e0498eea 100644
--- a/test/SemaObjC/class-bitfield.m
+++ b/test/SemaObjC/class-bitfield.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fobjc-fragile-abi -fsyntax-only -verify
@interface X
{
diff --git a/test/SemaObjC/class-protocol-method-match.m b/test/SemaObjC/class-protocol-method-match.m
new file mode 100644
index 000000000000..04243e967757
--- /dev/null
+++ b/test/SemaObjC/class-protocol-method-match.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s
+// rdar://9352731
+
+@protocol Bar
+@required
+- (bycopy id)bud; // expected-note {{previous declaration is here}}
+- (unsigned char) baz; // expected-note {{previous declaration is here}}
+- (char) ok;
+- (void) also_ok;
+@end
+
+@protocol Bar1
+@required
+- (unsigned char) baz; // expected-note {{previous declaration is here}}
+- (unsigned char) also_ok; // expected-note {{previous declaration is here}}
+- (void) ban : (int) arg, ...; // expected-note {{previous declaration is here}}
+@end
+
+@protocol Baz <Bar, Bar1>
+- (void) bar : (unsigned char)arg; // expected-note {{previous declaration is here}}
+- (void) ok;
+- (char) bak; // expected-note {{previous declaration is here}}
+@end
+
+@interface Foo <Baz>
+- (id)bud; // expected-warning {{conflicting distributed object modifiers on return type in declaration of 'bud'}}
+- (void) baz; // expected-warning 2 {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}}
+- (void) bar : (unsigned char*)arg; // expected-warning {{conflicting parameter types in declaration of 'bar:': 'unsigned char' vs 'unsigned char *'}}
+- (void) ok;
+- (void) also_ok; // expected-warning {{conflicting return type in declaration of 'also_ok': 'unsigned char' vs 'void'}}
+- (void) still_ok;
+- (void) ban : (int) arg; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+@end
+
+@interface Foo()
+- (void) bak;
+@end
+
+@implementation Foo
+- (bycopy id)bud { return 0; }
+- (void) baz {}
+- (void) bar : (unsigned char*)arg {}
+- (void) ok {}
+- (void) also_ok {}
+- (void) still_ok {}
+- (void) ban : (int) arg {}
+- (void) bak {} // expected-warning {{conflicting return type in declaration of 'bak': 'char' vs 'void'}}
+@end
diff --git a/test/SemaObjC/class-unavail-warning.m b/test/SemaObjC/class-unavail-warning.m
index 408647ac11c1..b2bd38831101 100644
--- a/test/SemaObjC/class-unavail-warning.m
+++ b/test/SemaObjC/class-unavail-warning.m
@@ -2,17 +2,35 @@
// rdar://9092208
__attribute__((unavailable("not available")))
-@interface MyClass { // expected-note 5 {{declaration has been explicitly marked unavailable here}}
+@interface MyClass { // expected-note 8 {{declaration has been explicitly marked unavailable here}}
@public
void *_test;
+ MyClass *ivar; // no error.
}
- (id)self;
- new;
+ (void)addObject:(id)anObject;
+- (MyClass *)meth; // no error.
@end
+@interface Foo {
+ MyClass *ivar; // expected-error {{unavailable}}
+}
+- (MyClass *)meth; // expected-error {{unavailable}}
+@end
+
+@interface MyClass (Cat1)
+- (MyClass *)meth; // no error.
+@end
+
+@interface MyClass (Cat2) // no error.
+@end
+
+@implementation MyClass (Cat2) // expected-error {{unavailable}}
+@end
+
int main() {
[MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
[MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
diff --git a/test/SemaObjC/comptypes-10.m b/test/SemaObjC/comptypes-10.m
index 0a2219099fb6..1a6533a600ea 100644
--- a/test/SemaObjC/comptypes-10.m
+++ b/test/SemaObjC/comptypes-10.m
@@ -32,3 +32,21 @@ void test(id <NSCopying, NSPROTO, NSPROTO2> bar)
{
NSObject <NSCopying> *Init = bar; // expected-warning {{initializing 'NSObject<NSCopying> *' with an expression of incompatible type 'id<NSCopying,NSPROTO,NSPROTO2>'}}
}
+
+// rdar://8843851
+@interface NSObject (CAT)
++ (struct S*)Meth : (struct S*)arg;
+@end
+
+struct S {
+ char *types;
+};
+
+@interface I
+@end
+
+@implementation I
+- (struct S *)Meth : (struct S*)a {
+ return [NSObject Meth : a];
+}
+@end
diff --git a/test/SemaObjC/comptypes-7.m b/test/SemaObjC/comptypes-7.m
index df627e5300ad..ef0f158c49ee 100644
--- a/test/SemaObjC/comptypes-7.m
+++ b/test/SemaObjC/comptypes-7.m
@@ -30,7 +30,7 @@ int main()
obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
obj_p = j; // expected-warning {{ incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
- obj_c = i; // expected-warning {{ incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
+ obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
diff --git a/test/SemaObjC/conflict-atomic-property.m b/test/SemaObjC/conflict-atomic-property.m
new file mode 100644
index 000000000000..033980c38c73
--- /dev/null
+++ b/test/SemaObjC/conflict-atomic-property.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10260017
+
+@interface Foo
+@property (nonatomic, assign, atomic) float dummy; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@property (nonatomic, assign) float d1;
+@property (atomic, assign) float d2;
+@property (assign) float d3;
+@property (atomic, nonatomic, assign) float d4; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@end
diff --git a/test/SemaObjC/conflict-nonfragile-abi2.m b/test/SemaObjC/conflict-nonfragile-abi2.m
index 5d6b2810fc10..7c95d5d57b5e 100644
--- a/test/SemaObjC/conflict-nonfragile-abi2.m
+++ b/test/SemaObjC/conflict-nonfragile-abi2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only %s
// rdar://8225011
int glob;
diff --git a/test/SemaObjC/conflicting-ivar-test-1.m b/test/SemaObjC/conflicting-ivar-test-1.m
index 1c68a23d7e28..01b35314aa98 100644
--- a/test/SemaObjC/conflicting-ivar-test-1.m
+++ b/test/SemaObjC/conflicting-ivar-test-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s
@interface INTF
{
diff --git a/test/SemaObjC/continuation-class-property.m b/test/SemaObjC/continuation-class-property.m
index c48a23d62a9b..a579184060b7 100644
--- a/test/SemaObjC/continuation-class-property.m
+++ b/test/SemaObjC/continuation-class-property.m
@@ -22,3 +22,22 @@
@property (readwrite, copy) id foos;
@end
+
+// rdar://10142679
+@class NSString;
+
+typedef struct {
+ float width;
+ float length;
+} NSRect;
+
+@interface MyClass {
+}
+@property (readonly) NSRect foo; // expected-note {{property declared here}}
+@property (readonly, strong) NSString *bar; // expected-note {{property declared here}}
+@end
+
+@interface MyClass ()
+@property (readwrite) NSString *foo; // expected-warning {{type of property 'NSString *' in continuation class does not match property type in primary class}}
+@property (readwrite, strong) NSRect bar; // expected-warning {{type of property 'NSRect' in continuation class does not match property type in primary class}}
+@end
diff --git a/test/SemaObjC/crash-label.m b/test/SemaObjC/crash-label.m
index 405d6bfd49e4..b0ca5b508ca4 100644
--- a/test/SemaObjC/crash-label.m
+++ b/test/SemaObjC/crash-label.m
@@ -1,10 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
- - (NSDictionary*) _executeScript:(NSString *)source { // expected-error 2 {{expected a type}} \
- // expected-error {{missing context for method declaration}}
-Exit: [nilArgs release]; // expected-error {{use of undeclared identifier}}
+ - (NSDictionary*) _executeScript:(NSString *)source { // expected-error 2 {{expected a type}} \
+ // expected-error {{missing context for method declaration}}
+Exit: [nilArgs release];
}
- (NSDictionary *) _setupKernelStandardMode:(NSString *)source { // expected-error 2 {{expected a type}} \
-expected-error {{missing context for method declaration}} \
-expected-note{{to match this '{'}}
- Exit: if(_ciKernel && !success ) { // expected-error {{use of undeclared identifier}} // expected-error 2 {{expected}} expected-note{{to match this '{'}} expected-error{{use of undeclared identifier 'success'}}
+ // expected-error {{missing context for method declaration}}
+ Exit: if(_ciKernel && !success ) {
diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m
index a55834dd3016..1e763af62c0a 100644
--- a/test/SemaObjC/default-synthesize-1.m
+++ b/test/SemaObjC/default-synthesize-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
@interface NSObject
- (void) release;
@@ -25,12 +25,12 @@
//@synthesize howMany, what;
- (int) howMany {
- return howMany;
+ return _howMany;
}
// - (void) setHowMany: (int) value
- (NSString*) what {
- return what;
+ return _what;
}
// - (void) setWhat: (NSString*) value
@end
@@ -46,14 +46,14 @@
// - (int) howMany
- (void) setHowMany: (int) value {
- howMany = value;
+ _howMany = value;
}
// - (NSString*) what
- (void) setWhat: (NSString*) value {
- if (what != value) {
- [what release];
- what = [value retain];
+ if (_what != value) {
+ [_what release];
+ _what = [value retain];
}
}
@end
@@ -68,19 +68,19 @@
//@synthesize howMany, what; // REM: Redundant anyway
- (int) howMany {
- return howMany;
+ return howMany; // expected-error {{use of undeclared identifier 'howMany'}}
}
- (void) setHowMany: (int) value {
- howMany = value;
+ howMany = value; // expected-error {{use of undeclared identifier 'howMany'}}
}
- (NSString*) what {
- return what;
+ return what; // expected-error {{use of undeclared identifier 'what'}}
}
- (void) setWhat: (NSString*) value {
- if (what != value) {
- [what release];
- what = [value retain];
+ if (what != value) { // expected-error {{use of undeclared identifier 'what'}}
+ [what release]; // expected-error {{use of undeclared identifier 'what'}}
+ what = [value retain]; // expected-error {{use of undeclared identifier 'what'}}
}
}
@end
diff --git a/test/SemaObjC/default-synthesize-2.m b/test/SemaObjC/default-synthesize-2.m
new file mode 100644
index 000000000000..1ea492ef5795
--- /dev/null
+++ b/test/SemaObjC/default-synthesize-2.m
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// rdar://8843851
+
+@interface StopAccessingIvarsDirectlyExample
+@property(strong) id name, rank, serialNumber;
+@end
+
+@implementation StopAccessingIvarsDirectlyExample
+
+- (void)identifyYourSelf {
+ if (self.name && self.rank && self.serialNumber)
+ self.name = 0;
+}
+
+// @synthesize name, rank, serialNumber;
+// default synthesis allows direct access to property ivars.
+- (id)init {
+ _name = _rank = _serialNumber = 0;
+ return self;
+}
+
+- (void)dealloc {
+}
+@end
+
+
+// Test2
+@interface Test2
+@property(strong, nonatomic) id object;
+@end
+
+// object has user declared setter/getter so it won't be
+// default synthesized; thus causing user error.
+@implementation Test2
+- (id) bar { return object; } // expected-error {{use of undeclared identifier 'object'}}
+- (void)setObject:(id)newObject {}
+- (id)object { return 0; }
+@end
+
+// Test3
+@interface Test3
+{
+ id uid;
+}
+@property (readwrite, assign) id uid;
+@end
+
+@implementation Test3
+// Oops, forgot to write @synthesize! will be default synthesized
+- (void) myMethod {
+ self.uid = 0; // Use of the “setter”
+ uid = 0; // Use of the wrong instance variable
+ _uid = 0; // Use of the property instance variable
+}
+@end
+
+@interface Test4 {
+ id _var;
+}
+@property (readwrite, assign) id var;
+@end
+
+
+// default synthesize property named 'var'
+@implementation Test4
+- (id) myMethod {
+ return self->_var; // compiles because 'var' is synthesized by default
+}
+@end
+
+@interface Test5
+{
+ id _var;
+}
+@property (readwrite, assign) id var;
+@end
+
+// default synthesis of property 'var'
+@implementation Test5
+- (id) myMethod {
+ Test5 *foo = 0;
+ return foo->_var; // OK
+}
+@end
+
+@interface Test6
+{
+ id _var; // expected-note {{'_var' declared here}}
+}
+@property (readwrite, assign) id var;
+@end
+
+// no default synthesis. So error is expected.
+@implementation Test6
+- (id) myMethod
+{
+ return var; // expected-error {{use of undeclared identifier 'var'}}
+}
+@synthesize var = _var;
+@end
+
+int* _object;
+
+@interface Test7
+@property (readwrite, assign) id object;
+@end
+
+// With default synthesis, '_object' is be the synthesized ivar not the global
+// 'int*' object. So no error.
+@implementation Test7
+- (id) myMethod {
+ return _object;
+}
+@end
+
diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m
index 33e3bd6f3464..0d2f47339900 100644
--- a/test/SemaObjC/default-synthesize.m
+++ b/test/SemaObjC/default-synthesize.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
@interface NSString @end
@@ -97,10 +97,10 @@
// rdar://7920807
@interface C @end
@interface C (Category)
-@property int p; // expected-warning {{property 'p' requires method 'p' to be defined }} \
- // expected-warning {{property 'p' requires method 'setP:' to be defined}}
+@property int p; // expected-note 2 {{property declared here}}
@end
-@implementation C (Category) // expected-note 2 {{implementation is here}}
+@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \
+ // expected-warning {{property 'p' requires method 'setP:' to be defined}}
@end
// Don't complain if a property is already @synthesized by usr.
diff --git a/test/SemaObjC/deref-interface.m b/test/SemaObjC/deref-interface.m
index 255e1d079814..490e3a565d2e 100644
--- a/test/SemaObjC/deref-interface.m
+++ b/test/SemaObjC/deref-interface.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only %s
@interface NSView
- (id)initWithView:(id)realView;
diff --git a/test/SemaObjC/direct-synthesized-ivar-access.m b/test/SemaObjC/direct-synthesized-ivar-access.m
index a72fb5f19c7a..7e57a29b18ac 100644
--- a/test/SemaObjC/direct-synthesized-ivar-access.m
+++ b/test/SemaObjC/direct-synthesized-ivar-access.m
@@ -1,14 +1,15 @@
-// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
// rdar://8673791
+// rdar://9943851
@interface I {
}
-@property int IVAR; // expected-note {{property declared here}}
+@property int IVAR;
- (int) OK;
@end
@implementation I
-- (int) Meth { return IVAR; } // expected-warning {{direct access of synthesized ivar by using property access 'IVAR'}}
+- (int) Meth { return _IVAR; }
- (int) OK { return self.IVAR; }
@end
diff --git a/test/SemaObjC/duplicate-ivar-in-class-extension.m b/test/SemaObjC/duplicate-ivar-in-class-extension.m
index 0507b352f602..9b9d58cc671d 100644
--- a/test/SemaObjC/duplicate-ivar-in-class-extension.m
+++ b/test/SemaObjC/duplicate-ivar-in-class-extension.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface Root @end
diff --git a/test/SemaObjC/enum-fixed-type.m b/test/SemaObjC/enum-fixed-type.m
new file mode 100644
index 000000000000..530ee0fe9995
--- /dev/null
+++ b/test/SemaObjC/enum-fixed-type.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if !__has_feature(objc_fixed_enum)
+# error Enumerations with a fixed underlying type are not supported
+#endif
+
+typedef long Integer;
+
+typedef enum : Integer { Enumerator1, Enumerator2 } Enumeration;
+
+int array[sizeof(Enumeration) == sizeof(long)? 1 : -1];
+
+
+enum Color { Red, Green, Blue };
+
+struct X {
+ enum Color : 4;
+ enum Color field1: 4;
+ enum Other : Integer field2;
+ enum Other : Integer field3 : 4;
+ enum : Integer { Blah, Blarg } field4 : 4;
+};
+
+void test() {
+ long value = 2;
+ Enumeration e = value;
+}
diff --git a/test/SemaObjC/error-property-gc-attr.m b/test/SemaObjC/error-property-gc-attr.m
index 829c08228747..25fee051174b 100644
--- a/test/SemaObjC/error-property-gc-attr.m
+++ b/test/SemaObjC/error-property-gc-attr.m
@@ -3,7 +3,7 @@
@interface INTF
{
- id IVAR;
+ id IVAR; // expected-note {{ivar is declared here}}
__weak id II;
__weak id WID;
id ID;
diff --git a/test/SemaObjC/iboutletcollection-attr.m b/test/SemaObjC/iboutletcollection-attr.m
index 5c82c8308a43..6bfe31389546 100644
--- a/test/SemaObjC/iboutletcollection-attr.m
+++ b/test/SemaObjC/iboutletcollection-attr.m
@@ -19,12 +19,13 @@ typedef void *PV;
__attribute__((iboutletcollection(I, 1))) id ivar1; // expected-error {{attribute takes one argument}}
__attribute__((iboutletcollection(B))) id ivar2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
__attribute__((iboutletcollection(PV))) id ivar3; // expected-error {{invalid type 'PV' as argument of iboutletcollection attribute}}
- __attribute__((iboutletcollection(PV))) void *ivar4; // expected-error {{ivar with iboutletcollection attribute must have object type (invalid 'void *')}}
+ __attribute__((iboutletcollection(PV))) void *ivar4; // expected-error {{ivar with 'iboutletcollection' attribute must be an object type (invalid 'void *')}}
__attribute__((iboutletcollection(int))) id ivar5; // expected-error {{type argument of iboutletcollection attribute cannot be a builtin type}}
+ __attribute__((iboutlet)) int ivar6; // expected-error {{ivar with 'iboutlet' attribute must be an object type}}
}
@property (nonatomic, retain) __attribute__((iboutletcollection(I,2,3))) id prop1; // expected-error {{attribute takes one argument}}
@property (nonatomic, retain) __attribute__((iboutletcollection(B))) id prop2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
-@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-error {{property with iboutletcollection attribute must have object type (invalid 'int')}}
+@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-error {{property with 'iboutletcollection' attribute must be an object type (invalid 'int')}}
@end
diff --git a/test/SemaObjC/id-isa-ref.m b/test/SemaObjC/id-isa-ref.m
index a75f2f336751..dfc0a5b9fdac 100644
--- a/test/SemaObjC/id-isa-ref.m
+++ b/test/SemaObjC/id-isa-ref.m
@@ -22,7 +22,7 @@ static void func() {
Whatever *y;
// GCC allows this, with the following warning:
- // instance variable ‘isa’ is @protected; this will be a hard error in the future
+ // instance variable 'isa' is @protected; this will be a hard error in the future
//
// FIXME: see if we can avoid the 2 warnings that follow the error.
[(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \
diff --git a/test/SemaObjC/incomplete-implementation.m b/test/SemaObjC/incomplete-implementation.m
index 612c331ae8c2..f5c5a7cc1813 100644
--- a/test/SemaObjC/incomplete-implementation.m
+++ b/test/SemaObjC/incomplete-implementation.m
@@ -1,26 +1,27 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface I
-- Meth; // expected-note{{method definition for 'Meth' not found}}
+- Meth; // expected-note{{method definition for 'Meth' not found}} \
+ // expected-note{{method declared here}}
@end
@implementation I // expected-warning{{incomplete implementation}}
@end
@implementation I(CAT)
-- Meth {return 0;}
+- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
@end
#pragma GCC diagnostic ignored "-Wincomplete-implementation"
@interface I2
-- Meth;
+- Meth; // expected-note{{method declared here}}
@end
@implementation I2
@end
@implementation I2(CAT)
-- Meth {return 0;}
+- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
@end
diff --git a/test/SemaObjC/instancetype.m b/test/SemaObjC/instancetype.m
new file mode 100644
index 000000000000..13d6e0309f82
--- /dev/null
+++ b/test/SemaObjC/instancetype.m
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if !__has_feature(objc_instancetype)
+# error Missing 'instancetype' feature macro.
+#endif
+
+@interface Root
++ (instancetype)alloc;
+- (instancetype)init; // expected-note{{overridden method is part of the 'init' method family}}
+- (instancetype)self;
+- (Class)class;
+
+@property (assign) Root *selfProp;
+- (instancetype)selfProp;
+@end
+
+@protocol Proto1
+@optional
+- (instancetype)methodInProto1;
+@end
+
+@protocol Proto2
+@optional
+- (instancetype)methodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+- (instancetype)otherMethodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+@end
+
+@interface Subclass1 : Root
+- (instancetype)initSubclass1;
+- (void)methodOnSubclass1;
++ (instancetype)allocSubclass1;
+@end
+
+@interface Subclass2 : Root
+- (instancetype)initSubclass2;
+- (void)methodOnSubclass2;
+@end
+
+// Sanity check: the basic initialization pattern.
+void test_instancetype_alloc_init_simple() {
+ Root *r1 = [[Root alloc] init];
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+}
+
+// Test that message sends to instancetype methods have the right type.
+void test_instancetype_narrow_method_search() {
+ // instancetype on class methods
+ Subclass1 *sc1 = [[Subclass1 alloc] initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
+ Subclass2 *sc2 = [[Subclass2 alloc] initSubclass2]; // okay
+
+ // instancetype on instance methods
+ [[[Subclass1 alloc] init] methodOnSubclass2]; // expected-warning{{'Subclass1' may not respond to 'methodOnSubclass2'}}
+ [[[Subclass2 alloc] init] methodOnSubclass2];
+
+ // instancetype on class methods using protocols
+ typedef Subclass1<Proto1> SC1Proto1;
+ typedef Subclass1<Proto2> SC1Proto2;
+ [[SC1Proto1 alloc] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [[SC1Proto2 alloc] methodInProto2];
+
+ // instancetype on instance methods
+ Subclass1<Proto1> *sc1proto1 = 0;
+ [[sc1proto1 self] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ Subclass1<Proto2> *sc1proto2 = 0;
+ [[sc1proto2 self] methodInProto2];
+
+ // Exact type checks
+ typeof([[Subclass1 alloc] init]) *ptr1 = (Subclass1 **)0;
+ typeof([[Subclass2 alloc] init]) *ptr2 = (Subclass2 **)0;
+
+ // Message sends to Class.
+ Subclass1<Proto1> *sc1proto1_2 = [[[sc1proto1 class] alloc] init];
+
+ // Property access
+ [sc1proto1.self methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.self methodInProto2];
+ [Subclass1.alloc initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
+ [Subclass2.alloc initSubclass2];
+
+ [sc1proto1.selfProp methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.selfProp methodInProto2];
+}
+
+// Test that message sends to super methods have the right type.
+@interface Subsubclass1 : Subclass1
+- (instancetype)initSubclass1;
++ (instancetype)allocSubclass1;
+
+- (void)onlyInSubsubclass1;
+@end
+
+@implementation Subsubclass1
+- (instancetype)initSubclass1 {
+ // Check based on method search.
+ [[super initSubclass1] methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+ [super.initSubclass1 methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ self = [super init]; // common pattern
+
+ // Exact type check.
+ typeof([super initSubclass1]) *ptr1 = (Subsubclass1**)0;
+
+ return self;
+}
+
++ (instancetype)allocSubclass1 {
+ // Check based on method search.
+ [[super allocSubclass1] methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ // The ASTs don't model super property accesses well enough to get this right
+ [super.allocSubclass1 methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ // Exact type check.
+ typeof([super allocSubclass1]) *ptr1 = (Subsubclass1**)0;
+
+ return [super allocSubclass1];
+}
+
+- (void)onlyInSubsubclass1 {}
+@end
+
+// Check compatibility rules for inheritance of related return types.
+@class Subclass4;
+
+@interface Subclass3 <Proto1, Proto2>
+- (Subclass3 *)methodInProto1;
+- (Subclass4 *)methodInProto2; // expected-warning{{method is expected to return an instance of its class type 'Subclass3', but is declared to return 'Subclass4 *'}}
+@end
+
+@interface Subclass4 : Root
++ (Subclass4 *)alloc; // okay
+- (Subclass3 *)init; // expected-warning{{method is expected to return an instance of its class type 'Subclass4', but is declared to return 'Subclass3 *'}}
+- (id)self; // expected-note{{overridden method is part of the 'self' method family}}
+- (instancetype)initOther;
+@end
+
+@protocol Proto3 <Proto1, Proto2>
+@optional
+- (id)methodInProto1;
+- (Subclass1 *)methodInProto2;
+- (int)otherMethodInProto2; // expected-warning{{protocol method is expected to return an instance of the implementing class, but is declared to return 'int'}}
+@end
+
+@implementation Subclass4
++ (id)alloc {
+ return self; // expected-warning{{incompatible pointer types returning 'Class' from a function with result type 'Subclass4 *'}}
+}
+
+- (Subclass3 *)init { return 0; } // don't complain: we lost the related return type
+
+- (Subclass3 *)self { return 0; } // expected-warning{{method is expected to return an instance of its class type 'Subclass4', but is declared to return 'Subclass3 *'}}
+
+- (Subclass4 *)initOther { return 0; }
+
+@end
+
+// Check that inherited related return types influence the types of
+// message sends.
+void test_instancetype_inherited() {
+ [[Subclass4 alloc] initSubclass1]; // expected-warning{{'Subclass4' may not respond to 'initSubclass1'}}
+ [[Subclass4 alloc] initOther];
+}
+
+// Check that related return types tighten up the semantics of
+// Objective-C method implementations.
+@implementation Subclass2
+- (instancetype)initSubclass2 {
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+ return sc1; // expected-warning{{incompatible pointer types returning 'Subclass1 *' from a function with result type 'Subclass2 *'}}
+}
+- (void)methodOnSubclass2 {}
+- (id)self {
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+ return sc1; // expected-warning{{incompatible pointer types returning 'Subclass1 *' from a function with result type 'Subclass2 *'}}
+}
+@end
+
+@interface MyClass : Root
++ (int)myClassMethod;
+@end
+
+@implementation MyClass
++ (int)myClassMethod { return 0; }
+
+- (void)blah {
+ int i = [[MyClass self] myClassMethod];
+}
+
+@end
+
diff --git a/test/SemaObjC/interface-1.m b/test/SemaObjC/interface-1.m
index 91586c9bb34a..87c230742e35 100644
--- a/test/SemaObjC/interface-1.m
+++ b/test/SemaObjC/interface-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -fsyntax-only -verify
// rdar://5957506
@interface NSWhatever :
diff --git a/test/SemaObjC/interface-layout.m b/test/SemaObjC/interface-layout.m
index 72a7155644a0..a8a93f0a6eb3 100644
--- a/test/SemaObjC/interface-layout.m
+++ b/test/SemaObjC/interface-layout.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -triple i386-apple-darwin9
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple i386-apple-darwin9 -fobjc-fragile-abi
typedef struct objc_object {} *id;
typedef signed char BOOL;
typedef unsigned int NSUInteger;
diff --git a/test/SemaObjC/ivar-in-class-extension-error.m b/test/SemaObjC/ivar-in-class-extension-error.m
index 23a7491aafb1..cecaa33bcfcc 100644
--- a/test/SemaObjC/ivar-in-class-extension-error.m
+++ b/test/SemaObjC/ivar-in-class-extension-error.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s
// rdar://6812436
@interface A @end
diff --git a/test/SemaObjC/ivar-in-class-extension.m b/test/SemaObjC/ivar-in-class-extension.m
index b5772f6a4ca3..c9f138f40752 100644
--- a/test/SemaObjC/ivar-in-class-extension.m
+++ b/test/SemaObjC/ivar-in-class-extension.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface SomeClass @end
diff --git a/test/SemaObjC/ivar-in-implementations.m b/test/SemaObjC/ivar-in-implementations.m
index 74db3224007a..c4cfc10d5e40 100644
--- a/test/SemaObjC/ivar-in-implementations.m
+++ b/test/SemaObjC/ivar-in-implementations.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface Super @end
diff --git a/test/SemaObjC/ivar-sem-check-2.m b/test/SemaObjC/ivar-sem-check-2.m
index 28c795ee7fe1..bf884b3d9d27 100644
--- a/test/SemaObjC/ivar-sem-check-2.m
+++ b/test/SemaObjC/ivar-sem-check-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface Super {
id value2; // expected-note {{previously declared 'value2' here}}
diff --git a/test/SemaObjC/method-no-context.m b/test/SemaObjC/method-no-context.m
index 3c45beef0426..c0875493b44b 100644
--- a/test/SemaObjC/method-no-context.m
+++ b/test/SemaObjC/method-no-context.m
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-- im0 { // expected-note{{to match this '{'}} expected-error{{missing context for method declaration}}
+- im0 { // expected-error{{missing context for method declaration}}
int a; return 0;
-// expected-error{{expected '}'}}
diff --git a/test/SemaObjC/missing-atend-metadata.m b/test/SemaObjC/missing-atend-metadata.m
index 434706d3fafc..9b79c52d9629 100644
--- a/test/SemaObjC/missing-atend-metadata.m
+++ b/test/SemaObjC/missing-atend-metadata.m
@@ -10,7 +10,7 @@
@end
@implementation I1 // expected-error {{'@end' is missing in implementation context}}
--(void) im0 { self = [super init]; } // expected-warning {{nstance method '-init' not found }}
+-(void) im0 { self = [super init]; }
@interface I2 : I0
- I2meth;
diff --git a/test/SemaObjC/missing-method-return-type.m b/test/SemaObjC/missing-method-return-type.m
new file mode 100644
index 000000000000..b62a0466ad35
--- /dev/null
+++ b/test/SemaObjC/missing-method-return-type.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wmissing-method-return-type -fsyntax-only -verify %s
+// rdar://9615045
+
+@interface I
+- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+@end
+
+@implementation I
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+@end
+
diff --git a/test/SemaObjC/nested-typedef-decl.m b/test/SemaObjC/nested-typedef-decl.m
new file mode 100644
index 000000000000..70ca3a12cc0f
--- /dev/null
+++ b/test/SemaObjC/nested-typedef-decl.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10041908
+
+@interface Bar {
+ struct _A *_hardlinkList;
+}
+@end
+@implementation Bar
+typedef struct _A {
+ int dev;
+ int inode;
+} A;
+
+- (void) idx:(int)idx ino:(int)ino dev:(int)dev
+{
+ _hardlinkList[idx].inode = ino;
+ _hardlinkList[idx].dev = dev;
+}
+@end
+
diff --git a/test/SemaObjC/objc-buffered-methods.m b/test/SemaObjC/objc-buffered-methods.m
new file mode 100644
index 000000000000..78912aed8605
--- /dev/null
+++ b/test/SemaObjC/objc-buffered-methods.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8843851
+
+int* global;
+
+@interface I
+- (void) Meth;
+@property int prop;
+@property int prop1;
+@end
+
+@implementation I
++ (void) _defaultMinSize { };
+static void _initCommon() {
+ Class graphicClass;
+ [graphicClass _defaultMinSize];
+}
+
+- (void) Meth { [self Forw]; } // No warning now
+- (void) Forw {}
+- (int) func { return prop; } // compiles - synthesized ivar will be accessible here.
+- (int)get_g { return global; } // No warning here - synthesized ivar will be accessible here.
+@synthesize prop;
+@synthesize prop1=global;
+@end
diff --git a/test/SemaObjC/property-and-class-extension.m b/test/SemaObjC/property-and-class-extension.m
index 926538af61c9..7040078416cd 100644
--- a/test/SemaObjC/property-and-class-extension.m
+++ b/test/SemaObjC/property-and-class-extension.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
/**
When processing @synthesize, treat ivars in a class extension the same as ivars in the class @interface,
diff --git a/test/SemaObjC/property-and-ivar-use.m b/test/SemaObjC/property-and-ivar-use.m
index 70e553469907..12874e7d201e 100644
--- a/test/SemaObjC/property-and-ivar-use.m
+++ b/test/SemaObjC/property-and-ivar-use.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// Do not issue error if 'ivar' used previously belongs to the inherited class
// and has same name as @dynalic property in current class.
diff --git a/test/SemaObjC/property-category-1.m b/test/SemaObjC/property-category-1.m
index 26e73136d01f..6382826080fb 100644
--- a/test/SemaObjC/property-category-1.m
+++ b/test/SemaObjC/property-category-1.m
@@ -37,7 +37,7 @@ int main(int argc, char **argv) {
///
@interface I0
-@property(readonly) int p0; // expected-warning {{property 'p0' requires method 'p0' to be defined}}
+@property(readonly) int p0; // expected-note {{property declared here}}
@end
@interface I0 (Cat0)
@@ -46,7 +46,7 @@ int main(int argc, char **argv) {
@interface I0 (Cat1)
@end
-@implementation I0 // expected-note {{implementation is here}}
+@implementation I0 // expected-warning {{property 'p0' requires method 'p0' to be define}}
- (void) foo {
self.p0 = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
}
diff --git a/test/SemaObjC/property-category-2.m b/test/SemaObjC/property-category-2.m
index e63672bb0ad7..ecc368162bfa 100644
--- a/test/SemaObjC/property-category-2.m
+++ b/test/SemaObjC/property-category-2.m
@@ -4,8 +4,7 @@
@protocol MyProtocol
@property float myFloat;
-@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 }}
+@property float anotherFloat; // expected-note 2 {{property declared}}
@end
@interface MyObject { float anotherFloat; }
@@ -14,7 +13,8 @@
@interface MyObject (CAT) <MyProtocol>
@end
-@implementation MyObject (CAT) // expected-note 2 {{implementation is here}}
+@implementation MyObject (CAT) // expected-warning {{property 'anotherFloat' requires method}} \
+ // expected-warning {{property 'anotherFloat' requires method 'setAnotherFloat:'}}
@dynamic myFloat; // OK
@synthesize anotherFloat; // expected-error {{@synthesize not allowed in a category's implementation}}
@end
diff --git a/test/SemaObjC/property-category-3.m b/test/SemaObjC/property-category-3.m
index 237de0f1f5fb..2a61d9272477 100644
--- a/test/SemaObjC/property-category-3.m
+++ b/test/SemaObjC/property-category-3.m
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@protocol P
- @property(readonly) int X;
+ @property(readonly) int X; // expected-note {{property declared here}}
@end
@protocol P1<P>
diff --git a/test/SemaObjC/property-category-impl.m b/test/SemaObjC/property-category-impl.m
index 997949778c6e..21fdf1b6d4be 100644
--- a/test/SemaObjC/property-category-impl.m
+++ b/test/SemaObjC/property-category-impl.m
@@ -24,8 +24,8 @@
@end
@interface MyClass (public)
-@property(readwrite) int foo; // expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
+@property(readwrite) int foo; // expected-note {{property declared here}}
@end
-@implementation MyClass (public)// expected-note {{implementation is here}}
+@implementation MyClass (public)// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
@end
diff --git a/test/SemaObjC/property-inherited.m b/test/SemaObjC/property-inherited.m
index 11ef2befa99b..f5f1b420c229 100644
--- a/test/SemaObjC/property-inherited.m
+++ b/test/SemaObjC/property-inherited.m
@@ -21,7 +21,7 @@
id _delegate;
}
@property(nonatomic, assign) id<FooDelegate> delegate;
-@property(nonatomic, assign) id<BarDelegate> delegate2;
+@property(nonatomic, assign) id<BarDelegate> delegate2; // expected-note {{property declared here}}
@end
@interface Bar : Foo {
}
@@ -36,7 +36,7 @@
@interface Base : NSData
@property(assign) id ref;
@property(assign) Base *p_base;
-@property(assign) NSMutableData *p_data;
+@property(assign) NSMutableData *p_data; // expected-note {{property declared here}}
@end
@interface Data : Base
diff --git a/test/SemaObjC/property-nonfragile-abi.m b/test/SemaObjC/property-nonfragile-abi.m
index ae82cb7d9295..55bf91f383d4 100644
--- a/test/SemaObjC/property-nonfragile-abi.m
+++ b/test/SemaObjC/property-nonfragile-abi.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef signed char BOOL;
diff --git a/test/SemaObjC/property-ns-returns-not-retained-attr.m b/test/SemaObjC/property-ns-returns-not-retained-attr.m
index 187c93f3d3af..a209da884ed7 100644
--- a/test/SemaObjC/property-ns-returns-not-retained-attr.m
+++ b/test/SemaObjC/property-ns-returns-not-retained-attr.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s
// rdar://9636091
@interface I
diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m
index 4d00bd2b522d..7d1cb7a36160 100644
--- a/test/SemaObjC/property.m
+++ b/test/SemaObjC/property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fsyntax-only -verify %s
@interface I
{
@@ -11,8 +11,7 @@
@end
@interface I(CAT)
-@property int d1; // expected-warning {{property 'd1' requires method 'd1' to be defined }} \
- // expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
+@property int d1; // expected-note 2 {{property declared here}}
@end
@implementation I
@@ -23,7 +22,8 @@
@synthesize name; // OK! property with same name as an accessible ivar of same name
@end
-@implementation I(CAT) // expected-note 2 {{implementation is here}}
+@implementation I(CAT) // expected-warning {{property 'd1' requires method 'd1' to be defined }} \
+ // expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
@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
@@ -63,3 +63,5 @@ typedef id BYObjectIdentifier;
@property int treeController; // expected-error {{property has a previous declaration}}
@end
+// rdar://10127639
+@synthesize window; // expected-error {{missing context for property implementation declaration}}
diff --git a/test/SemaObjC/protocol-archane.m b/test/SemaObjC/protocol-archane.m
index 138c43d1a83a..992d3e4798c1 100644
--- a/test/SemaObjC/protocol-archane.m
+++ b/test/SemaObjC/protocol-archane.m
@@ -33,3 +33,10 @@ typedef struct objc_class *Class;
Class <SomeProtocol> UnfortunateGCCExtension;
+// rdar://10238337
+@protocol Broken @end
+@interface Crash @end
+@implementation Crash
+- (void)crashWith:(<Broken>)a { // expected-warning {{protocol qualifiers without 'id' is archaic}}
+}
+@end
diff --git a/test/SemaObjC/protocol-implementing-class-methods.m b/test/SemaObjC/protocol-implementing-class-methods.m
new file mode 100644
index 000000000000..f08a5a97d8b7
--- /dev/null
+++ b/test/SemaObjC/protocol-implementing-class-methods.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7020493
+
+@protocol P1
+@optional
+- (int) PMeth;
+@required
+- (void) : (double) arg; // expected-note {{method declared here}}
+@end
+
+@interface NSImage <P1>
+- (void) initialize; // expected-note {{method declared here}}
+@end
+
+@interface NSImage (AirPortUI)
+- (void) initialize;
+@end
+
+@interface NSImage()
+- (void) CEMeth; // expected-note {{method declared here}}
+@end
+
+@implementation NSImage (AirPortUI)
+- (void) initialize {NSImage *p=0; [p initialize]; } // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (int) PMeth{ return 0; }
+- (void) : (double) arg{}; // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (void) CEMeth {}; // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+@end
+
+// rdar://10014946
+typedef char BOOL;
+@interface I
+{
+ BOOL allowsDeleting;
+}
+@property (nonatomic, assign, readwrite) BOOL allowsDeleting;
+@end
+
+@implementation I(CAT)
+- (BOOL) allowsDeleting { return 1; }
+@end
diff --git a/test/SemaObjC/provisional-ivar-lookup.m b/test/SemaObjC/provisional-ivar-lookup.m
index 04d6a4193095..007c21b726a5 100644
--- a/test/SemaObjC/provisional-ivar-lookup.m
+++ b/test/SemaObjC/provisional-ivar-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
// rdar:// 8565343
@interface Foo {
diff --git a/test/SemaObjC/qualified-protocol-method-conflicts.m b/test/SemaObjC/qualified-protocol-method-conflicts.m
new file mode 100644
index 000000000000..0cff3ff46841
--- /dev/null
+++ b/test/SemaObjC/qualified-protocol-method-conflicts.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s
+// rdar://6191214
+
+@protocol Xint
+-(void) setX: (int) arg0; // expected-note {{previous declaration is here}}
++(int) C; // expected-note {{previous declaration is here}}
+@end
+
+@protocol Xfloat
+-(void) setX: (float) arg0; // expected-note 2 {{previous declaration is here}}
++(float) C; // expected-note 2 {{previous declaration is here}}
+@end
+
+@interface A <Xint, Xfloat>
+@end
+
+@implementation A
+-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}}
++(int) C {return 0; } // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}}
+@end
+
+@interface B <Xfloat, Xint>
+@end
+
+@implementation B
+-(void) setX: (float) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'int' vs 'float'}}
++ (float) C {return 0.0; } // expected-warning {{conflicting return type in declaration of 'C': 'int' vs 'float'}}
+@end
+
+@protocol Xint_float<Xint, Xfloat>
+@end
+
+@interface C<Xint_float>
+@end
+
+@implementation C
+-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}}
++ (int) C {return 0;} // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}}
+@end
diff --git a/test/SemaObjC/related-result-type-inference.m b/test/SemaObjC/related-result-type-inference.m
index 094f19a67129..11b4b9602e14 100644
--- a/test/SemaObjC/related-result-type-inference.m
+++ b/test/SemaObjC/related-result-type-inference.m
@@ -149,8 +149,8 @@ void test_inference() {
@end
// <rdar://problem/9340699>
-@interface G
-- (id)_ABC_init __attribute__((objc_method_family(init)));
+@interface G
+- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method declared here}}
@end
@interface G (Additions)
@@ -158,7 +158,7 @@ void test_inference() {
@end
@implementation G (Additions)
-- (id)_ABC_init {
+- (id)_ABC_init { // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
return 0;
}
- (id)_ABC_init2 {
diff --git a/test/SemaObjC/return.m b/test/SemaObjC/return.m
index 3a626e369603..4e70bde1edc1 100644
--- a/test/SemaObjC/return.m
+++ b/test/SemaObjC/return.m
@@ -14,7 +14,7 @@ void test2(int a) {
}
// PR5286
-void test3(int a) { // expected-warning {{function could be attribute 'noreturn'}}
+void test3(int a) { // expected-warning {{function 'test3' could be declared with attribute 'noreturn'}}
while (1) {
if (a)
@throw (id)0;
@@ -39,3 +39,12 @@ NSString *rdar_4289832() { // no-warning
}
}
+void exit(int) __attribute__((noreturn));
+@interface rdar10098695
+@end
+
+@implementation rdar10098695
+- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}}
+ exit(1);
+}
+@end
diff --git a/test/SemaObjC/self-declared-in-block.m b/test/SemaObjC/self-declared-in-block.m
index 21310953c2c5..25ce8ba59933 100644
--- a/test/SemaObjC/self-declared-in-block.m
+++ b/test/SemaObjC/self-declared-in-block.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -fobjc-nonfragile-abi -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify %s
// rdar://9154582
@interface Blocky @end
diff --git a/test/SemaObjC/sizeof-interface.m b/test/SemaObjC/sizeof-interface.m
index 65c8e49e0b87..43870a17a30f 100644
--- a/test/SemaObjC/sizeof-interface.m
+++ b/test/SemaObjC/sizeof-interface.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only %s
@class I0;
diff --git a/test/SemaObjC/super-class-protocol-conformance.m b/test/SemaObjC/super-class-protocol-conformance.m
index bf19c837f46a..32d5392ad4e0 100644
--- a/test/SemaObjC/super-class-protocol-conformance.m
+++ b/test/SemaObjC/super-class-protocol-conformance.m
@@ -4,7 +4,7 @@
@interface NSObject @end
@protocol TopProtocol
- @property (readonly) id myString; // expected-warning {{property 'myString' requires method 'myString' to be defined}}
+ @property (readonly) id myString; // expected-note {{property}}
@end
@protocol SubProtocol <TopProtocol>
@@ -21,7 +21,7 @@
@implementation SubClass1 @end // Test1 - No Warning
-@implementation TopClass // expected-note {{implementation is here}}
+@implementation TopClass // expected-warning {{property 'myString' requires method 'myString' to be defined}}
@end
@implementation SubClass // Test3 - No Warning
@@ -39,11 +39,11 @@
@implementation SubClass4 @end // Test 5 - No Warning
@protocol NewProtocol
- @property (readonly) id myNewString; // expected-warning {{property 'myNewString' requires method 'myNewString' to be defined}}
+ @property (readonly) id myNewString; // expected-note {{property}}
@end
@interface SubClass5 : SubClass4 <NewProtocol> @end
-@implementation SubClass5 @end // expected-note {{implementation is here}}
+@implementation SubClass5 @end // expected-warning {{property 'myNewString' requires method 'myNewString' to be defined}}
// Radar 8035776
@@ -54,10 +54,10 @@
@end
@protocol ProtocolWithProperty <SuperProtocol>
-@property (readonly, assign) id invalidationBacktrace; // expected-warning {{property 'invalidationBacktrace' requires method 'invalidationBacktrace' to be defined}}
+@property (readonly, assign) id invalidationBacktrace; // expected-note {{property}}
@end
@interface INTF : Super <ProtocolWithProperty>
@end
-@implementation INTF @end // expected-note {{implementation is here}}
+@implementation INTF @end // expected-warning{{property 'invalidationBacktrace' requires method 'invalidationBacktrace' to be defined}}
diff --git a/test/SemaObjC/synth-provisional-ivars-1.m b/test/SemaObjC/synth-provisional-ivars-1.m
index 33de173cc14b..8bf687811fd2 100644
--- a/test/SemaObjC/synth-provisional-ivars-1.m
+++ b/test/SemaObjC/synth-provisional-ivars-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
// rdar://8913053
typedef unsigned char BOOL;
diff --git a/test/SemaObjC/synth-provisional-ivars.m b/test/SemaObjC/synth-provisional-ivars.m
index e8179aaa00dd..696eb9b38558 100644
--- a/test/SemaObjC/synth-provisional-ivars.m
+++ b/test/SemaObjC/synth-provisional-ivars.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
int bar;
@@ -18,7 +18,7 @@ int bar;
@end
@implementation I
-- (int) Meth { return PROP; } // expected-note 2{{'PROP' declared here}}
+- (int) Meth { return _PROP; }
@dynamic PROP1;
- (int) Meth1 { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}}
@@ -30,12 +30,12 @@ int bar;
@synthesize PROP3=IVAR;
- (int) Meth4 { return PROP4; }
-@synthesize PROP4=PROP4;
+@synthesize PROP4=PROP4; // expected-note 4 {{'PROP4' declared here}}
-- (int) Meth5 { return bar; } // expected-error {{use of undeclared identifier 'bar'}}
+- (int) Meth5 { return bar; }
@synthesize bar = _bar;
-- (int) Meth6 { return bar1; }
+- (int) Meth6 { return _bar1; }
@end
@@ -45,6 +45,6 @@ int bar;
@implementation I(r8251648)
- (int) Meth1: (int) bar {
- return bar; // expected-warning {{local declaration of 'bar' hides instance variable}}
+ return bar;
}
@end
diff --git a/test/SemaObjC/synthesized-ivar.m b/test/SemaObjC/synthesized-ivar.m
index 4786d808fa2f..745fe77449ac 100644
--- a/test/SemaObjC/synthesized-ivar.m
+++ b/test/SemaObjC/synthesized-ivar.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
@interface I
{
}
@@ -31,8 +31,8 @@ int f0(I *a) { return a->IP; } // expected-error {{instance variable 'IP' is pri
@implementation I1
- (int) Meth {
- PROP_INMAIN = 1;
- PROP_INCLASSEXT = 2;
+ _PROP_INMAIN = 1;
+ _PROP_INCLASSEXT = 2;
protected_ivar = 1; // OK
return private_ivar; // OK
}
@@ -45,8 +45,8 @@ int f0(I *a) { return a->IP; } // expected-error {{instance variable 'IP' is pri
@implementation DER
- (int) Meth {
protected_ivar = 1; // OK
- PROP_INMAIN = 1; // expected-error {{instance variable 'PROP_INMAIN' is private}}
- PROP_INCLASSEXT = 2; // expected-error {{instance variable 'PROP_INCLASSEXT' is private}}
+ _PROP_INMAIN = 1; // expected-error {{instance variable '_PROP_INMAIN' is private}}
+ _PROP_INCLASSEXT = 2; // expected-error {{instance variable '_PROP_INCLASSEXT' is private}}
return private_ivar; // expected-error {{instance variable 'private_ivar' is private}}
}
@end
diff --git a/test/SemaObjC/undeclared-selector.m b/test/SemaObjC/undeclared-selector.m
index 758e1d7f5602..af52fde8806e 100644
--- a/test/SemaObjC/undeclared-selector.m
+++ b/test/SemaObjC/undeclared-selector.m
@@ -18,7 +18,7 @@ typedef struct objc_selector *SEL;
+ (void) methodD
{
SEL d = @selector(methodD); /* Ok */
- SEL e = @selector(methodE); // expected-warning {{undeclared selector 'methodE'}}
+ SEL e = @selector(methodE);
}
- (void) methodE
diff --git a/test/SemaObjC/unimplemented-protocol-prop.m b/test/SemaObjC/unimplemented-protocol-prop.m
index d3de50efea58..fa3ed8ef121c 100644
--- a/test/SemaObjC/unimplemented-protocol-prop.m
+++ b/test/SemaObjC/unimplemented-protocol-prop.m
@@ -2,14 +2,12 @@
@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}}
+@property float MyProperty0; // expected-note 2 {{property declared}}
@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}}
+@property float MyProperty; // expected-note 2 {{property declared}}
@optional
@property float OptMyProperty;
@end
@@ -17,4 +15,25 @@
@interface I <PROTOCOL>
@end
-@implementation I @end // expected-note 4 {{implementation is here}}
+@implementation I @end // expected-warning {{property 'MyProperty0' requires method 'MyProperty0' to be defined}} \
+ // expected-warning {{property 'MyProperty0' requires method 'setMyProperty0:' to be defined}}\
+ // expected-warning {{property 'MyProperty' requires method 'MyProperty' to be defined}} \
+ // expected-warning {{property 'MyProperty' requires method 'setMyProperty:' to be defined}}
+
+// rdar://10120691
+// property is implemented in super class. No warning
+
+@protocol PROTOCOL1
+@property int MyProp;
+@end
+
+@interface superclass
+@property int MyProp;
+@end
+
+@interface childclass : superclass <PROTOCOL1>
+@end
+
+@implementation childclass
+@end
+
diff --git a/test/SemaObjC/uninit-variables.m b/test/SemaObjC/uninit-variables.m
index b5c49184f4bc..cad0f54b2dd3 100644
--- a/test/SemaObjC/uninit-variables.m
+++ b/test/SemaObjC/uninit-variables.m
@@ -3,7 +3,7 @@
// Duplicated from uninit-variables.c.
// Test just to ensure the analysis is working.
int test1() {
- int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization}}
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
diff --git a/test/SemaObjC/warn-deprecated-implementations.m b/test/SemaObjC/warn-deprecated-implementations.m
index 7bcd10cc3e06..60da7b0c41dc 100644
--- a/test/SemaObjC/warn-deprecated-implementations.m
+++ b/test/SemaObjC/warn-deprecated-implementations.m
@@ -26,7 +26,8 @@ __attribute__((deprecated))
@implementation CL // expected-warning {{Implementing deprecated class}}
@end
-@implementation CL ( SomeCategory ) // expected-warning {{Implementing deprecated category}}
+@implementation CL ( SomeCategory ) // expected-warning {{'CL' is deprecated}} \
+ // expected-warning {{Implementing deprecated category}}
@end
@interface CL_SUB : CL // expected-warning {{'CL' is deprecated}}
diff --git a/test/SemaObjC/warn-implicit-atomic-property.m b/test/SemaObjC/warn-implicit-atomic-property.m
index 0b4590a42db7..ec8e84e20f0c 100644
--- a/test/SemaObjC/warn-implicit-atomic-property.m
+++ b/test/SemaObjC/warn-implicit-atomic-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wimplicit-atomic-properties -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wimplicit-atomic-properties -fobjc-default-synthesize-properties -verify %s
// rdar://8774580
@interface Super
diff --git a/test/SemaObjC/warn-missing-super.m b/test/SemaObjC/warn-missing-super.m
new file mode 100644
index 000000000000..0169a6157258
--- /dev/null
+++ b/test/SemaObjC/warn-missing-super.m
@@ -0,0 +1,57 @@
+@protocol NSCopying @end
+
+@interface NSObject <NSCopying>
+- (void)dealloc;
+@end
+
+@implementation NSObject
+- (void)dealloc {
+ // Root class, shouldn't warn
+}
+- (void)finalize {
+ // Root class, shouldn't warn
+}
+@end
+
+@interface Subclass1 : NSObject
+- (void)dealloc;
+- (void)finalize;
+@end
+
+@implementation Subclass1
+- (void)dealloc {
+}
+- (void)finalize {
+}
+@end
+
+@interface Subclass2 : NSObject
+- (void)dealloc;
+- (void)finalize;
+@end
+
+@implementation Subclass2
+- (void)dealloc {
+ [super dealloc]; // Shouldn't warn
+}
+- (void)finalize {
+ [super finalize]; // Shouldn't warn
+}
+@end
+
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// CHECK: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
+// CHECK: 1 warning generated.
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
+// CHECK-GC: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
+// CHECK-GC: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC: 2 warnings generated.
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
+// CHECK-GC-ONLY: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC-ONLY: 1 warning generated.
+
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
+// CHECK-ARC: warn-missing-super.m:35:4: error: ARC forbids explicit message send of 'dealloc'
+// CHECK-ARC: 1 error generated.
diff --git a/test/SemaObjC/warn-retain-cycle.m b/test/SemaObjC/warn-retain-cycle.m
index 71385b8400bb..596858f83a3e 100644
--- a/test/SemaObjC/warn-retain-cycle.m
+++ b/test/SemaObjC/warn-retain-cycle.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -verify %s
@interface Test0
- (void) setBlock: (void(^)(void)) block;
@@ -27,7 +27,7 @@ void test0(Test0 *x) {
}
@interface BlockOwner
-@property (retain) void (^strong)(void);
+@property (retain) void (^strong)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
@end
@interface Test1 {
diff --git a/test/SemaObjC/weak-property.m b/test/SemaObjC/weak-property.m
index f0006076413d..bea66281ea7b 100644
--- a/test/SemaObjC/weak-property.m
+++ b/test/SemaObjC/weak-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
// rdar://8899430
@interface WeakPropertyTest {