summaryrefslogtreecommitdiff
path: root/test/SemaObjC
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
commit4c8b24812ddcd1dedaca343a6d4e76f91f398981 (patch)
tree137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/SemaObjC
parent5362a71c02e7d448a8ce98cf00c47e353fba5d04 (diff)
Notes
Diffstat (limited to 'test/SemaObjC')
-rw-r--r--test/SemaObjC/access-property-getter.m1
-rw-r--r--test/SemaObjC/attr-malloc.m16
-rw-r--r--test/SemaObjC/block-explicit-return-type.m77
-rw-r--r--test/SemaObjC/blocks.m11
-rw-r--r--test/SemaObjC/call-super-2.m4
-rw-r--r--test/SemaObjC/category-1.m19
-rw-r--r--test/SemaObjC/category-method-lookup-2.m1
-rw-r--r--test/SemaObjC/class-bitfield.m6
-rw-r--r--test/SemaObjC/class-getter-using-dotsyntax.m39
-rw-r--r--test/SemaObjC/class-impl-1.m2
-rw-r--r--test/SemaObjC/compatible-protocol-qualified-types.m1
-rw-r--r--test/SemaObjC/comptypes-1.m4
-rw-r--r--test/SemaObjC/comptypes-3.m12
-rw-r--r--test/SemaObjC/comptypes-5.m4
-rw-r--r--test/SemaObjC/comptypes-7.m4
-rw-r--r--test/SemaObjC/comptypes-a.m1
-rw-r--r--test/SemaObjC/conditional-expr-3.m6
-rw-r--r--test/SemaObjC/conditional-expr-4.m20
-rw-r--r--test/SemaObjC/conditional-expr-5.m27
-rw-r--r--test/SemaObjC/conditional-expr.m83
-rw-r--r--test/SemaObjC/crash-label.m9
-rw-r--r--test/SemaObjC/deref-interface.m12
-rw-r--r--test/SemaObjC/format-arg-attribute.m3
-rw-r--r--test/SemaObjC/id-isa-ref.m37
-rw-r--r--test/SemaObjC/id.m2
-rw-r--r--test/SemaObjC/interface-scope-2.m2
-rw-r--r--test/SemaObjC/invalid-objc-decls-1.m8
-rw-r--r--test/SemaObjC/message.m2
-rw-r--r--test/SemaObjC/method-arg-decay.m1
-rw-r--r--test/SemaObjC/method-conflict.m4
-rw-r--r--test/SemaObjC/method-encoding-2.m4
-rw-r--r--test/SemaObjC/method-lookup-2.m5
-rw-r--r--test/SemaObjC/method-lookup.m1
-rw-r--r--test/SemaObjC/method-typecheck-1.m11
-rw-r--r--test/SemaObjC/no-warn-unimpl-method.m2
-rw-r--r--test/SemaObjC/nonnull.m42
-rw-r--r--test/SemaObjC/nsobject-attribute.m2
-rw-r--r--test/SemaObjC/objc2-merge-gc-attribue-decl.m5
-rw-r--r--test/SemaObjC/property-11.m1
-rw-r--r--test/SemaObjC/property-9-impl-method.m3
-rw-r--r--test/SemaObjC/property-error-readonly-assign.m23
-rw-r--r--test/SemaObjC/property-expression-error.m18
-rw-r--r--test/SemaObjC/property-method-lookup-impl.m4
-rw-r--r--test/SemaObjC/property-missing.m2
-rw-r--r--test/SemaObjC/protocol-archane.m3
-rw-r--r--test/SemaObjC/protocol-attribute.m4
-rw-r--r--test/SemaObjC/protocol-implementation-inherited.m2
-rw-r--r--test/SemaObjC/protocol-lookup.m1
-rw-r--r--test/SemaObjC/protocol-qualified-class-unsupported.m2
-rw-r--r--test/SemaObjC/rdr-6211479-array-property.m3
-rw-r--r--test/SemaObjC/return.m6
-rw-r--r--test/SemaObjC/selector-1.m13
-rw-r--r--test/SemaObjC/sizeof-interface.m11
-rw-r--r--test/SemaObjC/static-ivar-ref-1.m3
-rw-r--r--test/SemaObjC/super-cat-prot.m4
-rw-r--r--test/SemaObjC/super.m1
-rw-r--r--test/SemaObjC/synchronized.m2
-rw-r--r--test/SemaObjC/undef-superclass-1.m7
-rw-r--r--test/SemaObjC/unused.m33
-rw-r--r--test/SemaObjC/warn-assign-property-nscopying.m15
-rw-r--r--test/SemaObjC/warn-superclass-method-mismatch.m50
-rw-r--r--test/SemaObjC/weak-attr-ivar.m5
62 files changed, 629 insertions, 77 deletions
diff --git a/test/SemaObjC/access-property-getter.m b/test/SemaObjC/access-property-getter.m
index 50a301688905b..225d63b0173c7 100644
--- a/test/SemaObjC/access-property-getter.m
+++ b/test/SemaObjC/access-property-getter.m
@@ -31,5 +31,6 @@
- (id)harvestPredictivelyProcessedOutputFiles
{
_outputStream.release;
+ return 0;
}
@end
diff --git a/test/SemaObjC/attr-malloc.m b/test/SemaObjC/attr-malloc.m
new file mode 100644
index 0000000000000..6cd6be00a8cf1
--- /dev/null
+++ b/test/SemaObjC/attr-malloc.m
@@ -0,0 +1,16 @@
+// RUN: clang-cc -verify -fsyntax-only -fblocks %s
+
+@interface TestAttrMallocOnMethods {}
+- (id) test1 __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+- (int) test2 __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+@end
+
+id bar(void) __attribute((malloc)); // no-warning
+
+typedef void (^bptr)(void);
+bptr baz(void) __attribute((malloc)); // no-warning
+
+__attribute((malloc)) id (*f)(); // expected-warning {{functions returning a pointer type}}
+__attribute((malloc)) bptr (*g)(); // expected-warning {{functions returning a pointer type}}
+__attribute((malloc)) void *(^h)(); // expected-warning {{functions returning a pointer type}}
+
diff --git a/test/SemaObjC/block-explicit-return-type.m b/test/SemaObjC/block-explicit-return-type.m
new file mode 100644
index 0000000000000..cfe72de39523d
--- /dev/null
+++ b/test/SemaObjC/block-explicit-return-type.m
@@ -0,0 +1,77 @@
+// RUN: clang-cc -fsyntax-only %s -verify -fblocks
+// FIXME: should compile
+// Test for blocks with explicit return type specified.
+
+typedef float * PF;
+float gf;
+
+@interface NSView
+ - (id) some_method_that_returns_id;
+@end
+
+NSView *some_object;
+
+void some_func (NSView * (^) (id));
+
+typedef struct dispatch_item_s *dispatch_item_t;
+typedef void (^completion_block_t)(void);
+
+typedef double (^myblock)(int);
+double test(myblock I);
+
+int main() {
+ __block int x = 1;
+ __block int y = 2;
+
+ (void)^void *{ return 0; };
+
+ (void)^float(float y){ return y; };
+
+ (void)^double (float y, double d) {
+ if (y)
+ return d;
+ else
+ return y;
+ };
+
+ const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) {
+ if (flag)
+ return 0;
+ if (flag == 1)
+ return arg;
+ else if (flag == 2)
+ return "";
+ return arg1;
+ };
+
+ (void)^PF { return &gf; };
+
+ some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; });
+
+ double res = test(^(int z){x = y+z; return (double)z; });
+}
+
+void func() {
+ completion_block_t X;
+
+ completion_block_t (^blockx)(dispatch_item_t) = ^completion_block_t (dispatch_item_t item) {
+ return X;
+ };
+
+ completion_block_t (^blocky)(dispatch_item_t) = ^(dispatch_item_t item) {
+ return X;
+ };
+
+ blockx = blocky;
+}
+
+
+// intent: block taking int returning block that takes char,int and returns int
+int (^(^block)(double x))(char, short);
+
+void foo() {
+ int one = 1;
+ block = ^(double x){ return ^(char c, short y) { return one + c + y; };}; // expected-error {{returning block that lives on the local stack}}
+ // or:
+ block = ^(double x){ return ^(char c, short y) { return one + (int)c + y; };}; // expected-error {{returning block that lives on the local stack}}
+}
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 6dab289ae9f22..aecdfd1f5e4e7 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -44,3 +44,14 @@ void foo8() {
P = ^itf() {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}}
P = ^itf{}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value}}
}
+
+
+int foo9() {
+ typedef void (^DVTOperationGroupScheduler)();
+ id _suboperationSchedulers;
+
+ for (DVTOperationGroupScheduler scheduler in _suboperationSchedulers) {
+ ;
+ }
+
+}
diff --git a/test/SemaObjC/call-super-2.m b/test/SemaObjC/call-super-2.m
index 92bec27c67835..a481cffd2886d 100644
--- a/test/SemaObjC/call-super-2.m
+++ b/test/SemaObjC/call-super-2.m
@@ -40,8 +40,8 @@ id objc_getClass(const char *s);
{
int i = [(id <Func>)self class_func0];
i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
- i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}}
- return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}}
+ i += [(Class <Func>)self class_func0]; //
+ return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
}
+ (int) class_func3
{
diff --git a/test/SemaObjC/category-1.m b/test/SemaObjC/category-1.m
index 6ae775848e78b..dcbda42cd1364 100644
--- a/test/SemaObjC/category-1.m
+++ b/test/SemaObjC/category-1.m
@@ -53,4 +53,23 @@
@implementation XCRemoteComputerManager
@end
+@implementation XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
+@end
+
+@implementation XCRemoteComputerManager(x) // expected-error {{reimplementation of category 'x' for class 'XCRemoteComputerManager'}}
+@end
+
+// <rdar://problem/7249233>
+
+@protocol MultipleCat_P
+-(void) im0;
+@end
+
+@interface MultipleCat_I @end
+
+@interface MultipleCat_I() @end
+@interface MultipleCat_I() <MultipleCat_P> @end
+
+@implementation MultipleCat_I // expected-warning {{incomplete implementation}}, expected-warning {{method definition for 'im0' not found}}
+@end
diff --git a/test/SemaObjC/category-method-lookup-2.m b/test/SemaObjC/category-method-lookup-2.m
index 76048cc2f74cf..15da63783fee6 100644
--- a/test/SemaObjC/category-method-lookup-2.m
+++ b/test/SemaObjC/category-method-lookup-2.m
@@ -17,6 +17,7 @@ typedef struct objc_class *Class;
- instanceMethod {
[[self class] classMethod];
+ return 0;
}
@end
diff --git a/test/SemaObjC/class-bitfield.m b/test/SemaObjC/class-bitfield.m
index 01b532464c289..82209121b1836 100644
--- a/test/SemaObjC/class-bitfield.m
+++ b/test/SemaObjC/class-bitfield.m
@@ -20,7 +20,7 @@
}
@end
-@interface WithBitfields: Base {
+@interface WithBitFields: Base {
void *isa; // expected-note {{previous definition is here}}
unsigned a: 5;
signed b: 4;
@@ -28,10 +28,10 @@
}
@end
-@implementation WithBitfields {
+@implementation WithBitFields {
char *isa; // expected-error {{instance variable 'isa' has conflicting type: 'char *' vs 'void *'}}
unsigned a: 5;
signed b: 4;
- int c: 3; // expected-error {{instance variable 'c' has conflicting bitfield width}}
+ int c: 3; // expected-error {{instance variable 'c' has conflicting bit-field width}}
}
@end
diff --git a/test/SemaObjC/class-getter-using-dotsyntax.m b/test/SemaObjC/class-getter-using-dotsyntax.m
new file mode 100644
index 0000000000000..ba42590c3419d
--- /dev/null
+++ b/test/SemaObjC/class-getter-using-dotsyntax.m
@@ -0,0 +1,39 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+
+struct objc_class {
+ Class isa;
+};
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@interface XCActivityLogSection
++ (unsigned)serializationFormatVersion;
++ (unsigned)sectionByDeserializingData;
++ (Class)retursClass;
+@end
+
+@implementation XCActivityLogSection
+
++ (unsigned)serializationFormatVersion
+{
+
+ return 0;
+}
++ (unsigned)sectionByDeserializingData {
+ unsigned version;
+ return self.serializationFormatVersion;
+}
+
++ (Class)retursClass {
+ Class version;
+ // FIXIT. (*version).isa does not work. Results in compiler error.
+ return version->isa;
+}
+
+@end
+
+
diff --git a/test/SemaObjC/class-impl-1.m b/test/SemaObjC/class-impl-1.m
index 5a67bef3d605b..09ad1556c035d 100644
--- a/test/SemaObjC/class-impl-1.m
+++ b/test/SemaObjC/class-impl-1.m
@@ -9,7 +9,7 @@ typedef int INTF3; // expected-note {{previous definition is here}}
@interface INTF : OBJECT
@end
-@implementation INTF @end
+@implementation INTF @end // expected-note {{previous definition is here}}
@implementation INTF // expected-error {{reimplementation of class 'INTF'}}
@end
diff --git a/test/SemaObjC/compatible-protocol-qualified-types.m b/test/SemaObjC/compatible-protocol-qualified-types.m
index 3c27b5f0d3cd6..71f00542b1c63 100644
--- a/test/SemaObjC/compatible-protocol-qualified-types.m
+++ b/test/SemaObjC/compatible-protocol-qualified-types.m
@@ -70,6 +70,7 @@ extern NSString * const XCActiveSelectionLevel;
- (NSTextStorage *)contents {
[_contents setDelegate:self]; // expected-warning {{incompatible type sending 'SKTText *', expected 'id<NSTextStorageDelegate>'}}
+ return 0;
}
@end
diff --git a/test/SemaObjC/comptypes-1.m b/test/SemaObjC/comptypes-1.m
index 8717bd09eb84b..df0785bf89e11 100644
--- a/test/SemaObjC/comptypes-1.m
+++ b/test/SemaObjC/comptypes-1.m
@@ -66,9 +66,7 @@ int main()
/* Any comparison between 'MyClass *' and anything which is not an 'id'
must generate a warning. */
- /* FIXME: GCC considers this a warning ("comparison of distinct pointer types"). */
- /* There is a corresponding FIXME in ASTContext::mergeTypes() */
- if (obj_p == obj_c) foo() ;
+ if (obj_p == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('id<MyProtocol>' and 'MyClass *')}}
if (obj_c == obj_cp) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'MyOtherClass *')}}
if (obj_cp == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('MyOtherClass *' and 'MyClass *')}}
diff --git a/test/SemaObjC/comptypes-3.m b/test/SemaObjC/comptypes-3.m
index 2d8f19d806a71..0506bce7ad1af 100644
--- a/test/SemaObjC/comptypes-3.m
+++ b/test/SemaObjC/comptypes-3.m
@@ -42,8 +42,8 @@ int main()
obj_ac = obj_b; // expected-warning {{incompatible type assigning 'id<MyProtocolB>', expected 'id<MyProtocolAC>'}}
obj_ac = obj_ab; // expected-warning {{incompatible type assigning 'id<MyProtocolAB>', expected 'id<MyProtocolAC>'}}
- if (obj_a == obj_b) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolA>' and 'id<MyProtocolB>')}}
- if (obj_b == obj_a) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolB>' and 'id<MyProtocolA>')}}
+ if (obj_a == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolA>' and 'id<MyProtocolB>')}}
+ if (obj_b == obj_a) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolA>')}}
if (obj_a == obj_ab) foo (); /* Ok */
if (obj_ab == obj_a) foo (); /* Ok */
@@ -54,11 +54,11 @@ int main()
if (obj_b == obj_ab) foo (); /* Ok */
if (obj_ab == obj_b) foo (); /* Ok */
- if (obj_b == obj_ac) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolB>' and 'id<MyProtocolAC>')}}
- if (obj_ac == obj_b) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolAC>' and 'id<MyProtocolB>')}}
+ if (obj_b == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolAC>')}}
+ if (obj_ac == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolB>')}}
- if (obj_ab == obj_ac) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolAB>' and 'id<MyProtocolAC>')}}
- if (obj_ac == obj_ab) foo (); // expected-warning {{invalid operands to binary expression ('id<MyProtocolAC>' and 'id<MyProtocolAB>')}}
+ if (obj_ab == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAB>' and 'id<MyProtocolAC>')}}
+ if (obj_ac == obj_ab) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolAB>')}}
return 0;
}
diff --git a/test/SemaObjC/comptypes-5.m b/test/SemaObjC/comptypes-5.m
index afd8a4949ed64..478e8c8114ac6 100644
--- a/test/SemaObjC/comptypes-5.m
+++ b/test/SemaObjC/comptypes-5.m
@@ -26,8 +26,8 @@ int main()
MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
MyClass<MyProtocol> *obj_c_cat_p_q = nil;
- obj_c_cat_p = obj_id_p; // expected-warning {{incompatible type assigning 'id<MyProtocol>', expected 'MyClass *'}}
- obj_c_super_p = obj_id_p; // expected-warning {{incompatible type assigning 'id<MyProtocol>', expected 'MyOtherClass *'}}
+ obj_c_cat_p = obj_id_p;
+ obj_c_super_p = obj_id_p;
obj_id_p = obj_c_cat_p; /* Ok */
obj_id_p = obj_c_super_p; /* Ok */
diff --git a/test/SemaObjC/comptypes-7.m b/test/SemaObjC/comptypes-7.m
index faca6937cb74a..881fd2b5553b8 100644
--- a/test/SemaObjC/comptypes-7.m
+++ b/test/SemaObjC/comptypes-7.m
@@ -28,7 +28,7 @@ int main()
obj = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'id'}}
obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'id<MyProtocol>'}}
- obj_p = j; // expected-warning {{incompatible type assigning 'int *', expected 'id<MyProtocol>'}}
+ obj_p = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'id<MyProtocol>'}}
obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'MyClass *'}}
obj_c = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'MyClass *'}}
@@ -42,7 +42,7 @@ int main()
i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning 'Class', expected 'int'}}
j = obj; // expected-warning {{incompatible pointer types assigning 'id', expected 'int *'}}
- j = obj_p; // expected-warning {{incompatible type assigning 'id<MyProtocol>', expected 'int *'}}
+ j = obj_p; // expected-warning {{incompatible pointer types assigning 'id<MyProtocol>', expected 'int *'}}
j = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'int *'}}
j = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'int *'}}
diff --git a/test/SemaObjC/comptypes-a.m b/test/SemaObjC/comptypes-a.m
index 936c6dfc5de90..5570d56b0b83b 100644
--- a/test/SemaObjC/comptypes-a.m
+++ b/test/SemaObjC/comptypes-a.m
@@ -13,6 +13,7 @@ extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context);
NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletionItem> b, void *context)
{
+ return 0;
}
@interface TedWantsToVerifyObjCDoesTheRightThing
diff --git a/test/SemaObjC/conditional-expr-3.m b/test/SemaObjC/conditional-expr-3.m
index 31d4834ff0af5..9f1ee68c6f94a 100644
--- a/test/SemaObjC/conditional-expr-3.m
+++ b/test/SemaObjC/conditional-expr-3.m
@@ -51,15 +51,15 @@ void f7(int cond, id x, A *a) {
}
void f8(int cond, id<P0,P1> x0, id<P0,P2> x1) {
- barP0(cond ? x0 : x1);
+ barP0(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
}
void f9(int cond, id<P0,P1> x0, id<P0,P2> x1) {
- barP1(cond ? x0 : x1);
+ barP1(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
}
void f10(int cond, id<P0,P1> x0, id<P0,P2> x1) {
- barP2(cond ? x0 : x1);
+ barP2(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
}
int f11(int cond, A* a, B* b) {
diff --git a/test/SemaObjC/conditional-expr-4.m b/test/SemaObjC/conditional-expr-4.m
index 7d50ba60750c7..87209581534c5 100644
--- a/test/SemaObjC/conditional-expr-4.m
+++ b/test/SemaObjC/conditional-expr-4.m
@@ -1,5 +1,4 @@
-// RUN: clang-cc -fsyntax-only %s
-// XFAIL
+// RUN: clang-cc -fsyntax-only -verify %s
// <rdar://problem/6212771>
#define nil ((void*) 0)
@@ -26,6 +25,11 @@ A *f1_a(int cond, A *a) {
return cond ? a : nil;
}
+void *f1_const_a(int x, void *p, const A * q) {
+ void *r = x ? p : q; // expected-warning{{initializing 'void const *' discards qualifiers, expected 'void *'}}
+ return r;
+}
+
// Check interaction with qualified id
@protocol P0 @end
@@ -48,9 +52,7 @@ id f3(int cond, id<P0> a) {
@end
int f5(int cond, id<P1> a, id<P1> b) {
- // This should result in something with id type, currently. This is
- // almost certainly wrong and should be fixed.
- return (cond ? a : b).x; // expected-error {{member reference base type ('id') is not a structure or union}}
+ return (cond ? a : b).x;
}
int f5_a(int cond, A *a, A *b) {
return (cond ? a : b).x;
@@ -61,7 +63,7 @@ int f5_b(int cond, A *a, B *b) {
int f6(int cond, id<P1> a, void *b) {
// This should result in something with id type, currently.
- return (cond ? a : b).x; // expected-error {{member reference base type ('id') is not a structure or union}}
+ return (cond ? a : b).x; // expected-error {{member reference base type 'void *' is not a structure or union}}
}
int f7(int cond, id<P1> a) {
@@ -69,10 +71,10 @@ int f7(int cond, id<P1> a) {
}
int f8(int cond, id<P1> a, A *b) {
- // GCC regards this as a warning (comparison of distinct Objective-C types lacks a cast)
- return a == b; // expected-error {{invalid operands to binary expression}}
+ return a == b; // expected-warning {{comparison of distinct pointer types ('id<P1>' and 'A *')}}
}
int f9(int cond, id<P1> a, A *b) {
- return (cond ? a : b).x; // expected-error {{incompatible operand types}}
+ return (cond ? a : b).x; // expected-warning {{incompatible operand types ('id<P1>' and 'A *')}} \
+ expected-error {{property 'x' not found on object of type 'id'}}
}
diff --git a/test/SemaObjC/conditional-expr-5.m b/test/SemaObjC/conditional-expr-5.m
new file mode 100644
index 0000000000000..d9c1a9474fe73
--- /dev/null
+++ b/test/SemaObjC/conditional-expr-5.m
@@ -0,0 +1,27 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface PBXBuildSettingsDictionary
+{
+ int i;
+}
+@end
+
+@interface XCConditionalBuildSettingsDictionary : PBXBuildSettingsDictionary
+{
+}
+@end
+
+@implementation PBXBuildSettingsDictionary
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet
+{
+ return i ? self : (id)0;
+}
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet2
+{
+ return i ? (id)0 : self;
+}
+@end
+
+
diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m
index ec3613b2aa9bc..2043503ddf7bd 100644
--- a/test/SemaObjC/conditional-expr.m
+++ b/test/SemaObjC/conditional-expr.m
@@ -27,9 +27,8 @@
@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'nextOutputStream' not found}}
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
- // GCC warns about both of these.
self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream2 *'}}
- return nextOutputStream ? nextOutputStream : self;
+ return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id<DTOutputStreams>' and 'DTFilterOutputStream2 *')}}
}
@end
@@ -37,8 +36,84 @@
@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}}
- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
id <DTOutputStreams> nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}}
- // GCC warns about both of these as well (no errors).
self = nextOutputStream; // expected-warning {{incompatible type assigning 'id<DTOutputStreams>', expected 'DTFilterOutputStream3 *'}}
- return nextOutputStream ? nextOutputStream : self;
+ return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id<DTOutputStreams>' and 'DTFilterOutputStream3 *')}}
}
@end
+
+//
+
+@protocol P0
+@property int intProp;
+@end
+@protocol P1
+@end
+@protocol P2
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+@interface C
+@end
+
+@interface D
+@end
+
+void f0(id<P0> x) {
+ x.intProp = 1;
+}
+
+void f1(int cond, id<P0> x, id<P0> y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f2(int cond, id<P0> x, A *y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f3(int cond, id<P0> x, B *y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f4(int cond, id x, B *y) {
+ (cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+void f5(int cond, id<P0> x, C *y) {
+ (cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types ('id<P0>' and 'C *')}} expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+void f6(int cond, C *x, D *y) {
+ (cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types}}, expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+id f7(int a, id<P0> x, A* p) {
+ return a ? x : p;
+}
+
+void f8(int a, A<P0> *x, A *y) {
+ [ (a ? x : y ) intProp ];
+}
+
+void f9(int a, A<P0> *x, A<P1> *y) {
+ id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')'}}
+ A<P0> *l1 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+ A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+ [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+}
+
+void f10(int a, id<P0> x, id y) {
+ [ (a ? x : y ) intProp ];
+}
+
+void f11(int a, id<P0> x, id<P1> y) {
+ [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('id<P0>' and 'id<P1>')}}
+}
+
+void f12(int a, A<P0> *x, A<P1> *y) {
+ A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+}
diff --git a/test/SemaObjC/crash-label.m b/test/SemaObjC/crash-label.m
new file mode 100644
index 0000000000000..ff40cc67c5dc6
--- /dev/null
+++ b/test/SemaObjC/crash-label.m
@@ -0,0 +1,9 @@
+// RUN: clang-cc -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 *) _setupKernelStandardMode:(NSString *)source { // expected-error 2 {{expected a type}} \
+expected-error {{missing context for method declaration}}
+ Exit: if(_ciKernel && !success ) { // expected-error {{use of undeclared identifier}} // expected-error 2 {{expected}}
diff --git a/test/SemaObjC/deref-interface.m b/test/SemaObjC/deref-interface.m
new file mode 100644
index 0000000000000..1c85918ed57ca
--- /dev/null
+++ b/test/SemaObjC/deref-interface.m
@@ -0,0 +1,12 @@
+// RUN: clang-cc -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
+
+@interface NSView
+ - (id)initWithView:(id)realView;
+@end
+
+@implementation NSView
+ - (id)initWithView:(id)realView {
+ *(NSView *)self = *(NSView *)realView; // expected-error {{indirection cannot be to an interface in non-fragile ABI}}
+ }
+@end
+
diff --git a/test/SemaObjC/format-arg-attribute.m b/test/SemaObjC/format-arg-attribute.m
index 60cc7cb44f25f..dc5aa8932cdab 100644
--- a/test/SemaObjC/format-arg-attribute.m
+++ b/test/SemaObjC/format-arg-attribute.m
@@ -11,8 +11,7 @@ extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expecte
struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
-// FIXME: We don't flag this yet.
-enum e1 { E1V0 } __attribute__((format_arg(1))); /* { dg-error "does not apply|only applies" "format_arg on enum" } */
+enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}}
extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute requires 1 argument(s)}}
diff --git a/test/SemaObjC/id-isa-ref.m b/test/SemaObjC/id-isa-ref.m
new file mode 100644
index 0000000000000..dc42f9a539650
--- /dev/null
+++ b/test/SemaObjC/id-isa-ref.m
@@ -0,0 +1,37 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Failing currently due to Obj-C type representation changes. 2009-09-17
+// XFAIL
+
+typedef struct objc_object {
+ struct objc_class *isa;
+} *id;
+
+@interface NSObject {
+ struct objc_class *isa;
+}
+@end
+@interface Whatever : NSObject
++self;
+@end
+
+static void func() {
+
+ id x;
+
+ [(*x).isa self];
+ [x->isa self];
+
+ Whatever *y;
+
+ // GCC allows this, with the following warning:
+ // 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}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+ [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+}
diff --git a/test/SemaObjC/id.m b/test/SemaObjC/id.m
index 1781ce71d9c33..70d981c42b171 100644
--- a/test/SemaObjC/id.m
+++ b/test/SemaObjC/id.m
@@ -15,6 +15,6 @@ void foo() {
}
// Test attempt to redefine 'id' in an incompatible fashion.
-typedef int id; // expected-error {{typedef redefinition with different types}}
+typedef int id; // FIXME: Decide how we want to deal with this (now that 'id' is more of a built-in type).
id b;
diff --git a/test/SemaObjC/interface-scope-2.m b/test/SemaObjC/interface-scope-2.m
index d054e714f3b2e..c9025903940c9 100644
--- a/test/SemaObjC/interface-scope-2.m
+++ b/test/SemaObjC/interface-scope-2.m
@@ -83,6 +83,7 @@ typedef struct __LoreStuffNode {} LoreStuffNode;
- init {
LoreStuffNode *node;
node = &(_historyStuff[1]);
+ return 0;
}
@end
@@ -108,6 +109,7 @@ _nfttFlags;
if (self != ((void *)0)) {
(void)memset(&_nfttFlags, 0, sizeof(struct _OingoBoingoContraptionPeonFlags));
}
+ return 0;
}
@end
diff --git a/test/SemaObjC/invalid-objc-decls-1.m b/test/SemaObjC/invalid-objc-decls-1.m
index e3a94f62d5a60..4a3732eff188a 100644
--- a/test/SemaObjC/invalid-objc-decls-1.m
+++ b/test/SemaObjC/invalid-objc-decls-1.m
@@ -32,3 +32,11 @@ Super foo( // expected-error{{interface interface type 'Super' cannot be returne
Super p1; // expected-error{{interface type cannot be statically allocated}}
return p1;
}
+
+@interface NSMutableSet @end
+
+@interface DVTDummyAnnotationProvider
+ @property(readonly) NSMutableSet annotations; // expected-error{{interface type cannot be statically allocated}}
+
+@end
+
diff --git a/test/SemaObjC/message.m b/test/SemaObjC/message.m
index 7b6a4ee3f796d..02901238f17f8 100644
--- a/test/SemaObjC/message.m
+++ b/test/SemaObjC/message.m
@@ -95,6 +95,6 @@ int test5(int X) {
void foo4() {
struct objc_object X[10];
- [X rect];
+ [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} expected-warning {{method '-rect' not found (return type defaults to 'id')}}
}
diff --git a/test/SemaObjC/method-arg-decay.m b/test/SemaObjC/method-arg-decay.m
index 4b045914c0958..7fd07d2ede336 100644
--- a/test/SemaObjC/method-arg-decay.m
+++ b/test/SemaObjC/method-arg-decay.m
@@ -87,6 +87,7 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
PBXModule *obj = [XCFindPossibleKeyModules(pModule, (BOOL)0) objectOfType:type matchingFunction:comparator usingData:data];
}
}
+ return 0;
}
- (BOOL)buffer:(char *)buf containsAnyPrompts:(char *[])prompts
{
diff --git a/test/SemaObjC/method-conflict.m b/test/SemaObjC/method-conflict.m
index 7a9b9f0beee84..a4213f6c63c9e 100644
--- a/test/SemaObjC/method-conflict.m
+++ b/test/SemaObjC/method-conflict.m
@@ -47,7 +47,9 @@ typedef NSUInteger XDSourceLanguage;
+ appendVisibility: (id <XDUMLNamedElement>) element withSpecification: (XDSCDisplaySpecification *) displaySpec to: (NSMutableAttributedString *) attributedString
{
+ return 0;
}
-+ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec {
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec {
+ return 0;
}
@end
diff --git a/test/SemaObjC/method-encoding-2.m b/test/SemaObjC/method-encoding-2.m
index 64a0bc4c323d0..b3ffdcd0585c2 100644
--- a/test/SemaObjC/method-encoding-2.m
+++ b/test/SemaObjC/method-encoding-2.m
@@ -7,6 +7,6 @@
@end
@implementation Intf
-- (in out bycopy id) address:(byref inout void *)location with:(out oneway unsigned **)arg2{}
-- (id) another:(void *)location with:(unsigned **)arg2 {}
+- (in out bycopy id) address:(byref inout void *)location with:(out oneway unsigned **)arg2{ return 0; }
+- (id) another:(void *)location with:(unsigned **)arg2 { return 0; }
@end
diff --git a/test/SemaObjC/method-lookup-2.m b/test/SemaObjC/method-lookup-2.m
index dd0bca93644ea..cca757509ad19 100644
--- a/test/SemaObjC/method-lookup-2.m
+++ b/test/SemaObjC/method-lookup-2.m
@@ -35,8 +35,8 @@ extern NSString *const NSWillBecomeMultiThreadedNotification;
@implementation SenTestTool
+ (void) initialize {}
-+(SenTestTool *) sharedInstance {}
--(int) run {}
++(SenTestTool *) sharedInstance { return 0; }
+-(int) run { return 0; }
+(int) run {
return[[self sharedInstance] run];
}
@@ -57,6 +57,7 @@ extern NSString *const NSWillBecomeMultiThreadedNotification;
- whatever {
id obj = [[XX alloc] init];
[[obj class] classMethod];
+ return 0;
}
@end
diff --git a/test/SemaObjC/method-lookup.m b/test/SemaObjC/method-lookup.m
index 917ad6b3ee92c..49dc789af7832 100644
--- a/test/SemaObjC/method-lookup.m
+++ b/test/SemaObjC/method-lookup.m
@@ -29,6 +29,7 @@ static NSMutableArray * recentCompletions = ((void *)0);
[(id)item setPriority:[item priority] / [PBXCodeAssistant factorForRecentCompletion:[item name]]];
}
}
+ return 0;
}
@end
diff --git a/test/SemaObjC/method-typecheck-1.m b/test/SemaObjC/method-typecheck-1.m
index d110c858a41ae..a53c4d9f416a8 100644
--- a/test/SemaObjC/method-typecheck-1.m
+++ b/test/SemaObjC/method-typecheck-1.m
@@ -8,8 +8,8 @@
@implementation A
-(void) setMoo: (float) x {} // expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}}
-- (char) setMoo1: (int) x {} // expected-warning {{conflicting return type in implementation of 'setMoo1:': 'int' vs 'char'}}
-- (int) setOk : (int) x : (double) d {}
+- (char) setMoo1: (int) x { return 0; } // expected-warning {{conflicting return type in implementation of 'setMoo1:': 'int' vs 'char'}}
+- (int) setOk : (int) x : (double) d { return 0; }
@end
@@ -20,7 +20,7 @@
@implementation C
+(float) cMoo: // expected-warning {{conflicting return type in implementation of 'cMoo:': 'void' vs 'float'}}
- (float) x {} // expected-warning {{conflicting parameter types in implementation of 'cMoo:': 'int' vs 'float'}}
+ (float) x { return 0; } // expected-warning {{conflicting parameter types in implementation of 'cMoo:': 'int' vs 'float'}}
@end
@@ -31,7 +31,6 @@
@implementation A(CAT)
-(float) setCat: // expected-warning {{conflicting return type in implementation of 'setCat:': 'void' vs 'float'}}
-(float) x {} // expected-warning {{conflicting parameter types in implementation of 'setCat:': 'int' vs 'float'}}
-+ (int) cCat: (int) x {} // expected-warning {{conflicting return type in implementation of 'cCat:': 'void' vs 'int'}}
+(float) x { return 0; } // expected-warning {{conflicting parameter types in implementation of 'setCat:': 'int' vs 'float'}}
++ (int) cCat: (int) x { return 0; } // expected-warning {{conflicting return type in implementation of 'cCat:': 'void' vs 'int'}}
@end
-
diff --git a/test/SemaObjC/no-warn-unimpl-method.m b/test/SemaObjC/no-warn-unimpl-method.m
index 756c47b2fe80d..2fcb06ff5e92d 100644
--- a/test/SemaObjC/no-warn-unimpl-method.m
+++ b/test/SemaObjC/no-warn-unimpl-method.m
@@ -38,5 +38,5 @@
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
}
- - (id) init {}
+ - (id) init { return 0; }
@end
diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m
new file mode 100644
index 0000000000000..869bbbd57e85e
--- /dev/null
+++ b/test/SemaObjC/nonnull.m
@@ -0,0 +1,42 @@
+// RUN: clang-cc -fblocks -fsyntax-only -verify %s
+
+@class NSObject;
+
+int f1(int x) __attribute__((nonnull)); // expected-warning{{'nonnull' attribute applied to function with no pointer arguments}}
+int f2(int *x) __attribute__ ((nonnull (1)));
+int f3(int *x) __attribute__ ((nonnull (0))); // expected-error {{'nonnull' attribute parameter 1 is out of bounds}}
+int f4(int *x, int *y) __attribute__ ((nonnull (1,2)));
+int f5(int *x, int *y) __attribute__ ((nonnull (2,1)));
+int f6(NSObject *x) __attribute__ ((nonnull (1))); // no-warning
+int f7(NSObject *x) __attribute__ ((nonnull)); // no-warning
+
+
+extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
+
+extern void func3 (void (^block1)(), int, void (^block2)(), int)
+__attribute__((nonnull(1,3)));
+
+extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
+__attribute__((nonnull(2)));
+
+void
+foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
+{
+ func1(cp1, cp2, i1);
+
+ func1(0, cp2, i1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func1(cp1, 0, i1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func1(cp1, cp2, 0);
+
+
+ func3(0, i2, cp3, i3); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func3(cp3, i2, 0, i3); // expected-warning {{null passed to a callee which requires a non-null argument}}
+
+ func4(0, cp1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func4(cp1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+
+ // Shouldn't these emit warnings? Clang doesn't, and neither does GCC. It
+ // seems that the checking should handle Objective-C pointers.
+ func6((NSObject*) 0); // no-warning
+ func7((NSObject*) 0); // no-warning
+}
diff --git a/test/SemaObjC/nsobject-attribute.m b/test/SemaObjC/nsobject-attribute.m
index 3544cb139aabd..c47b909846c1b 100644
--- a/test/SemaObjC/nsobject-attribute.m
+++ b/test/SemaObjC/nsobject-attribute.m
@@ -26,7 +26,7 @@ id getProperty(id self) {
@synthesize x=x;
@end
-int main(char *argc, char *argv[]) {
+int main(int argc, char *argv[]) {
HandTested *to;
to.x = tmp; // setter
if (tmp != to.x)
diff --git a/test/SemaObjC/objc2-merge-gc-attribue-decl.m b/test/SemaObjC/objc2-merge-gc-attribue-decl.m
index 9dae1efdcd2a8..0da0ce876d3e9 100644
--- a/test/SemaObjC/objc2-merge-gc-attribue-decl.m
+++ b/test/SemaObjC/objc2-merge-gc-attribue-decl.m
@@ -25,6 +25,5 @@ extern __strong id p5;
extern char* __strong p6; // expected-note {{previous definition is here}}
extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
-// FIXME. We do not issue error here because we don't put the attribute on the pointer type.
-extern __strong char* p7;
-extern char* p7;
+extern __strong char* p7; // expected-note {{previous definition is here}}
+extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
diff --git a/test/SemaObjC/property-11.m b/test/SemaObjC/property-11.m
index e8e60914716d5..bb36c2766e75a 100644
--- a/test/SemaObjC/property-11.m
+++ b/test/SemaObjC/property-11.m
@@ -29,6 +29,7 @@
o = x.foo;
[x setFoo:o];
x.foo = o;
+ return 0;
}
@end
diff --git a/test/SemaObjC/property-9-impl-method.m b/test/SemaObjC/property-9-impl-method.m
index c97f388911908..06cb30482c826 100644
--- a/test/SemaObjC/property-9-impl-method.m
+++ b/test/SemaObjC/property-9-impl-method.m
@@ -55,10 +55,11 @@ NSSize minimumSize;
@implementation OrganizerTabView
@dynamic tabHeaderView, headerRect, minimumSize;
--(CGFloat) tabAreaThickness {}
+-(CGFloat) tabAreaThickness { return 0; }
-(NSRectEdge) rectEdgeForTabs {
NSRect dummy, result = {};
NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs);
+ return 0;
}
@end
diff --git a/test/SemaObjC/property-error-readonly-assign.m b/test/SemaObjC/property-error-readonly-assign.m
index edeff09dfadd7..d5cef78f18f4a 100644
--- a/test/SemaObjC/property-error-readonly-assign.m
+++ b/test/SemaObjC/property-error-readonly-assign.m
@@ -19,3 +19,26 @@ void f0(A *a, B* b) {
b.ok = 20;
}
+typedef struct {
+ int i1, i2;
+} NSRect;
+
+NSRect NSMakeRect();
+
+@interface NSWindow
+{
+ NSRect _frame;
+}
+- (NSRect)frame;
+@end
+
+@interface NSWindow (Category)
+-(void)methodToMakeClangCrash;
+@end
+
+@implementation NSWindow (Category)
+-(void)methodToMakeClangCrash
+{
+ self.frame = NSMakeRect(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+}
+@end
diff --git a/test/SemaObjC/property-expression-error.m b/test/SemaObjC/property-expression-error.m
new file mode 100644
index 0000000000000..b648ee939dbed
--- /dev/null
+++ b/test/SemaObjC/property-expression-error.m
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface AddressMyProperties
+{
+ unsigned index;
+}
+@property unsigned index;
+@end
+
+@implementation AddressMyProperties
+@synthesize index;
+@end
+
+int main() {
+ AddressMyProperties *object;
+ &object.index; // expected-error {{address of property expression requested}}
+ return 0;
+}
diff --git a/test/SemaObjC/property-method-lookup-impl.m b/test/SemaObjC/property-method-lookup-impl.m
index ed7e9bcd43155..295bba524009c 100644
--- a/test/SemaObjC/property-method-lookup-impl.m
+++ b/test/SemaObjC/property-method-lookup-impl.m
@@ -8,9 +8,7 @@
@implementation SSyncCEList
-- (id) list
-{
-}
+- (id) list { return 0; }
@end
@interface SSyncConflictList : SSyncCEList
diff --git a/test/SemaObjC/property-missing.m b/test/SemaObjC/property-missing.m
index 1aa94ce71b257..301907ad1c7d7 100644
--- a/test/SemaObjC/property-missing.m
+++ b/test/SemaObjC/property-missing.m
@@ -17,6 +17,6 @@ void f2(id<NSCopying> o)
void f3(id o)
{
- o.foo; // expected-error{{member reference base type 'id' is not a structure or union}}
+ o.foo; // expected-error{{property 'foo' not found on object of type 'id'}}
}
diff --git a/test/SemaObjC/protocol-archane.m b/test/SemaObjC/protocol-archane.m
index 3e70c05096524..05f5103178f2b 100644
--- a/test/SemaObjC/protocol-archane.m
+++ b/test/SemaObjC/protocol-archane.m
@@ -28,8 +28,7 @@ typedef int NotAnObjCObjectType;
// GCC doesn't diagnose this.
NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
-// Decided not to support the following GCC extension. Found while researching rdar://6497631
typedef struct objc_class *Class;
-Class <SomeProtocol> UnfortunateGCCExtension; // expected-error {{protocol qualified 'Class' is unsupported}}
+Class <SomeProtocol> UnfortunateGCCExtension;
diff --git a/test/SemaObjC/protocol-attribute.m b/test/SemaObjC/protocol-attribute.m
index ae8441132c778..6bd58dd9a03ad 100644
--- a/test/SemaObjC/protocol-attribute.m
+++ b/test/SemaObjC/protocol-attribute.m
@@ -3,7 +3,7 @@
__attribute ((unavailable))
@protocol FwProto; // expected-note{{marked unavailable}}
-Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}}
__attribute ((deprecated)) @protocol MyProto1
@@ -31,7 +31,7 @@ __attribute ((deprecated)) @protocol MyProto1
-Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}}
@protocol FwProto @end // expected-note{{marked unavailable}}
diff --git a/test/SemaObjC/protocol-implementation-inherited.m b/test/SemaObjC/protocol-implementation-inherited.m
index 1aace211c844c..55b92ae6684af 100644
--- a/test/SemaObjC/protocol-implementation-inherited.m
+++ b/test/SemaObjC/protocol-implementation-inherited.m
@@ -26,7 +26,7 @@
@end
@implementation B1
--foo {};
+-foo { return 0; };
@end
// Interface conforms to a protocol whose methods are provided by an
diff --git a/test/SemaObjC/protocol-lookup.m b/test/SemaObjC/protocol-lookup.m
index 0f1860d2c88ed..87655bd9e7a01 100644
--- a/test/SemaObjC/protocol-lookup.m
+++ b/test/SemaObjC/protocol-lookup.m
@@ -44,6 +44,7 @@
[_foo release];
[_bar release];
[super dealloc];
+ return 0;
}
@end
diff --git a/test/SemaObjC/protocol-qualified-class-unsupported.m b/test/SemaObjC/protocol-qualified-class-unsupported.m
index ad1ed5dc9411a..6e344c1f44143 100644
--- a/test/SemaObjC/protocol-qualified-class-unsupported.m
+++ b/test/SemaObjC/protocol-qualified-class-unsupported.m
@@ -23,7 +23,7 @@ id objc_getClass(const char *s);
@interface Derived2: Object <Func>
@end
-static void doSomething(Class <Func> unsupportedObjectType) { // expected-error {{protocol qualified 'Class' is unsupported}}
+static void doSomething(Class <Func> unsupportedObjectType) {
[unsupportedObjectType class_func0];
}
diff --git a/test/SemaObjC/rdr-6211479-array-property.m b/test/SemaObjC/rdr-6211479-array-property.m
index f8e4a07cba584..1781c5a404028 100644
--- a/test/SemaObjC/rdr-6211479-array-property.m
+++ b/test/SemaObjC/rdr-6211479-array-property.m
@@ -1,9 +1,8 @@
// RUN: clang-cc -fsyntax-only -verify %s
-// XFAIL
// <rdar://problem/6211479>
typedef int T[2];
@interface A
-@property(assign) T p2; // expected-error {{FIXME: property has invalid type}}
+@property(assign) T p2; // expected-error {{property cannot have array or function type 'T' (aka 'int [2]')}}
@end
diff --git a/test/SemaObjC/return.m b/test/SemaObjC/return.m
new file mode 100644
index 0000000000000..9acf470799580
--- /dev/null
+++ b/test/SemaObjC/return.m
@@ -0,0 +1,6 @@
+// RUN: clang-cc %s -fsyntax-only -verify
+
+int test1() {
+ id a;
+ @throw a;
+}
diff --git a/test/SemaObjC/selector-1.m b/test/SemaObjC/selector-1.m
index ee77015041dbd..a969b100cc68f 100644
--- a/test/SemaObjC/selector-1.m
+++ b/test/SemaObjC/selector-1.m
@@ -8,6 +8,19 @@
@end
+@interface I
+- (id) compare: (char) arg1;
+@end
+
+@interface J
+- (id) compare: (id) arg1;
+@end
+
+SEL foo()
+{
+ return @selector(compare:); // Non warning on multiple selector found.
+}
+
int main() {
SEL s = @selector(retain);
SEL s1 = @selector(meth1:);
diff --git a/test/SemaObjC/sizeof-interface.m b/test/SemaObjC/sizeof-interface.m
index 75d7daafbbcc2..140a980311e4e 100644
--- a/test/SemaObjC/sizeof-interface.m
+++ b/test/SemaObjC/sizeof-interface.m
@@ -77,3 +77,14 @@ int bar(I0 *P) {
}
@end
+
+@interface Foo @end
+
+int foo()
+{
+ Foo *f;
+
+ // Both of these crash clang nicely
+ ++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
+ --f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
+}
diff --git a/test/SemaObjC/static-ivar-ref-1.m b/test/SemaObjC/static-ivar-ref-1.m
index 3c37e9e830265..6b1a31226b208 100644
--- a/test/SemaObjC/static-ivar-ref-1.m
+++ b/test/SemaObjC/static-ivar-ref-1.m
@@ -1,4 +1,5 @@
-// RUN: clang-cc -ast-print %s
+// RUN: clang-cc -triple i386-unknown-unknown -ast-print %s &&
+// RUN: clang-cc -triple x86_64-apple-darwin10 -ast-print %s
@interface current
{
diff --git a/test/SemaObjC/super-cat-prot.m b/test/SemaObjC/super-cat-prot.m
index 1ab0752faa38d..6ddc31fbb9e66 100644
--- a/test/SemaObjC/super-cat-prot.m
+++ b/test/SemaObjC/super-cat-prot.m
@@ -35,14 +35,16 @@ typedef struct _IBInset {} IBInset;
@interface NSView (NSView_IBViewProtocol) <IBViewProtocol> - (NSRect)layoutRect; @end
typedef enum { NSProTextFieldSquareBezel = 0, NSProTextFieldRoundedBezel = 1, NSProTextFieldDisplayBezel = 2 } MKModuleReusePolicy;
@implementation NSProBox(IBAdditions)
--(NSString *)inspectorClassName {}
+-(NSString *)inspectorClassName { return 0; }
-(IBInset)ibShadowInset {
if ([self boxType] == NSBoxSeparator) {
return [super ibShadowInset];
}
+ while (1) {}
}
-(NSSize)minimumFrameSizeFromKnobPosition:(IBKnobPosition)knobPosition {
if ([self boxType] != NSBoxSeparator)
return [super minimumFrameSizeFromKnobPosition:knobPosition];
+ while (1) {}
}
@end
diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m
index 9afd4eb983c57..83842afb9c3f2 100644
--- a/test/SemaObjC/super.m
+++ b/test/SemaObjC/super.m
@@ -21,6 +21,7 @@
+ classMethod {
[super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
+ return 0;
}
@end
diff --git a/test/SemaObjC/synchronized.m b/test/SemaObjC/synchronized.m
index 7131265b5bb7b..01f82c1686221 100644
--- a/test/SemaObjC/synchronized.m
+++ b/test/SemaObjC/synchronized.m
@@ -3,7 +3,7 @@
@interface PBXTrackableTaskManager @end
@implementation PBXTrackableTaskManager
-- (id) init {}
+- (id) init { return 0; }
- (void) unregisterTask:(id) task {
@synchronized (self) {
id taskID = [task taskIdentifier]; // expected-warning {{method '-taskIdentifier' not found (return type defaults to 'id')}}
diff --git a/test/SemaObjC/undef-superclass-1.m b/test/SemaObjC/undef-superclass-1.m
index 0d670f8c08092..cb15dc39a3dcb 100644
--- a/test/SemaObjC/undef-superclass-1.m
+++ b/test/SemaObjC/undef-superclass-1.m
@@ -24,3 +24,10 @@
[super dealloc]; // expected-error {{no super class declared in @interface for 'SUPER'}}
}
@end
+
+@interface RecursiveClass : RecursiveClass // expected-error {{trying to recursively use 'RecursiveClass' as superclass of 'RecursiveClass'}}
+@end
+
+@implementation RecursiveClass
+@end
+
diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m
index 88c6f1054c8d1..bbe3109a28173 100644
--- a/test/SemaObjC/unused.m
+++ b/test/SemaObjC/unused.m
@@ -1,4 +1,4 @@
-// RUN: clang-cc %s -verify -fsyntax-only
+// RUN: clang-cc %s -verify -Wunused -fsyntax-only
#include <stdio.h>
@interface Greeter
@@ -11,8 +11,33 @@
}
@end
-int main (void) {
- [Greeter hello];
- return 0;
+
+int test1(void) {
+ [Greeter hello];
+ return 0;
+}
+
+
+
+@interface NSObject @end
+@interface NSString : NSObject
+- (int)length;
+@end
+
+void test2() {
+ @"pointless example call for test purposes".length; // expected-warning {{property access result unused - getters should not have side effects}}
}
+
+
+
+
+@interface foo
+- (int)meth: (int)x: (int)y: (int)z ;
+@end
+
+@implementation foo
+- (int) meth: (int)x:
+(int)y: // expected-warning{{unused}}
+(int) __attribute__((unused))z { return x; }
+@end
diff --git a/test/SemaObjC/warn-assign-property-nscopying.m b/test/SemaObjC/warn-assign-property-nscopying.m
new file mode 100644
index 0000000000000..cf1acc466a274
--- /dev/null
+++ b/test/SemaObjC/warn-assign-property-nscopying.m
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fobjc-gc -fsyntax-only -verify %s
+
+@protocol NSCopying @end
+
+@interface NSObject <NSCopying>
+@end
+
+@interface NSDictionary : NSObject
+@end
+
+@interface INTF
+ @property NSDictionary* undoAction; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} // expected-warning {{default assign attribute on property 'undoAction' which implements NSCopying protocol is not appropriate with}}
+ @property id okAction; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}
+@end
+
diff --git a/test/SemaObjC/warn-superclass-method-mismatch.m b/test/SemaObjC/warn-superclass-method-mismatch.m
new file mode 100644
index 0000000000000..f123a3f2ddacd
--- /dev/null
+++ b/test/SemaObjC/warn-superclass-method-mismatch.m
@@ -0,0 +1,50 @@
+// RUN: clang-cc -fsyntax-only -Wsuper-class-method-mismatch -verify %s
+
+@interface Root
+-(void) method_r: (char)ch : (float*)f1 : (int*) x; // expected-note {{previous declaration is here}}
+@end
+
+@class Sub;
+
+@interface Base : Root
+-(void) method: (int*) x; // expected-note {{previous declaration is here}}
+-(void) method1: (Base*) x; // expected-note {{previous declaration is here}}
+-(void) method2: (Sub*) x;
++ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}}
++ mathod4: (id)x1;
+- method5: (int) x : (double) d; // expected-note {{previous declaration is here}}
+- method6: (int) x : (float) d; // expected-note {{previous declaration is here}}
+@end
+
+struct A {
+ int x,y,z;
+};
+
+@interface Sub : Base
+-(void) method: (struct A*) a; // expected-warning {{method parameter type 'struct A *' does not match super class method parameter type 'int *'}}
+-(void) method1: (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}}
+-(void) method2: (Base*) x; // no need to warn. At call point we warn if need be.
++ method3: (int)x1 : (Sub *)x2 : (float)x3; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}}
++ mathod4: (Base*)x1;
+-(void) method_r: (char)ch : (float*)f1 : (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'int *'}}
+- method5: (int) x : (float) d; // expected-warning {{method parameter type 'float' does not match super class method parameter type 'double'}}
+- method6: (int) x : (double) d; // expected-warning {{method parameter type 'double' does not match super class method parameter type 'float'}}
+@end
+
+void f(Base *base, Sub *sub) {
+ int x;
+ [base method:&x]; // warn. if base is actually 'Sub' it will use -[Sub method] with wrong arguments
+
+ Base *b;
+ [base method1:b]; // if base is actuall 'Sub' it will use [Sub method1] with wrong argument.
+
+ [base method2:b]; // expected-warning {{}}
+
+ Sub *s;
+ [base method2:s]; // if base is actually 'Sub' OK. Either way OK.
+
+}
+
+
+
+
diff --git a/test/SemaObjC/weak-attr-ivar.m b/test/SemaObjC/weak-attr-ivar.m
index 9e0e8cb4b3af3..6af96ddb3c8b2 100644
--- a/test/SemaObjC/weak-attr-ivar.m
+++ b/test/SemaObjC/weak-attr-ivar.m
@@ -45,8 +45,7 @@ typedef enum { Foo_HUH_NONE } FooHUHCode;
}
@property(copy) NSString *author;
- (BOOL) isInteresting;
-@end NSString *FooHUHCodeToString(FooHUHCode HUH) {
-}
+@end NSString *FooHUHCodeToString(FooHUHCode HUH) { return 0; }
@interface FooHUHCodeToStringTransformer: NSValueTransformer {
}
@end @implementation FooPlaypenEntry @synthesize author = _author;
@@ -62,12 +61,14 @@ typedef enum { Foo_HUH_NONE } FooHUHCode;
}
}
}
+ return 0;
}
- (FooHUHCode) HUH {
if (_HUH == Foo_HUH_NONE) {
if (_mostInterestingChild)
return [_mostInterestingChild HUH];
}
+ return 0;
}
@end