From 31236f87444b39db2857c82e22cfdb15f1fd9a16 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 26 Jul 2008 01:04:40 +0000 Subject: remove objc prefixes from these tests. llvm-svn: 54085 --- clang/test/SemaObjC/at-defs.m | 29 +++++++ clang/test/SemaObjC/bad-receiver-1.m | 9 +++ clang/test/SemaObjC/comptypes-1.m | 89 ++++++++++++++++++++++ clang/test/SemaObjC/comptypes-2.m | 37 +++++++++ clang/test/SemaObjC/comptypes-3.m | 64 ++++++++++++++++ clang/test/SemaObjC/comptypes-4.m | 25 ++++++ clang/test/SemaObjC/comptypes-5.m | 44 +++++++++++ clang/test/SemaObjC/comptypes-6.m | 16 ++++ clang/test/SemaObjC/comptypes-7.m | 70 +++++++++++++++++ clang/test/SemaObjC/comptypes-8.m | 12 +++ clang/test/SemaObjC/comptypes-9.m | 86 +++++++++++++++++++++ clang/test/SemaObjC/comptypes-a.m | 40 ++++++++++ clang/test/SemaObjC/interface-1.m | 17 +++++ clang/test/SemaObjC/interface-layout.m | 27 +++++++ clang/test/SemaObjC/ivar-lookup.m | 18 +++++ clang/test/SemaObjC/legacy-implementation-1.m | 11 +++ clang/test/SemaObjC/method-lookup-2.m | 40 ++++++++++ clang/test/SemaObjC/objc-at-defs.m | 29 ------- clang/test/SemaObjC/objc-bad-receiver-1.m | 9 --- clang/test/SemaObjC/objc-comptypes-1.m | 89 ---------------------- clang/test/SemaObjC/objc-comptypes-2.m | 37 --------- clang/test/SemaObjC/objc-comptypes-3.m | 64 ---------------- clang/test/SemaObjC/objc-comptypes-4.m | 25 ------ clang/test/SemaObjC/objc-comptypes-5.m | 44 ----------- clang/test/SemaObjC/objc-comptypes-6.m | 16 ---- clang/test/SemaObjC/objc-comptypes-7.m | 70 ----------------- clang/test/SemaObjC/objc-comptypes-8.m | 12 --- clang/test/SemaObjC/objc-comptypes-9.m | 86 --------------------- clang/test/SemaObjC/objc-interface-1.m | 17 ----- clang/test/SemaObjC/objc-interface-layout.m | 27 ------- clang/test/SemaObjC/objc-ivar-lookup.m | 18 ----- clang/test/SemaObjC/objc-legacy-implementation-1.m | 11 --- clang/test/SemaObjC/objc-method-lookup.m | 40 ---------- clang/test/SemaObjC/objc-property-1.m | 39 ---------- clang/test/SemaObjC/objc-property-2.m | 63 --------------- clang/test/SemaObjC/objc-property-3.m | 14 ---- clang/test/SemaObjC/objc-property-4.m | 30 -------- clang/test/SemaObjC/objc-property-5.m | 31 -------- clang/test/SemaObjC/objc-property-6.m | 69 ----------------- clang/test/SemaObjC/objc-property-7.m | 34 --------- clang/test/SemaObjC/objc-property-8.m | 74 ------------------ clang/test/SemaObjC/objc-property-9-impl-method.m | 63 --------------- clang/test/SemaObjC/objc-props-on-prots.m | 65 ---------------- clang/test/SemaObjC/objc-protocol-1.m | 14 ---- clang/test/SemaObjC/objc-string.m | 15 ---- clang/test/SemaObjC/objc-synchronized.m | 75 ------------------ clang/test/SemaObjC/objc-try-catch.m | 37 --------- clang/test/SemaObjC/objc-typedef-class.m | 78 ------------------- clang/test/SemaObjC/objc-types-compatible.m | 40 ---------- clang/test/SemaObjC/objc-unused.m | 18 ----- clang/test/SemaObjC/property-1.m | 39 ++++++++++ clang/test/SemaObjC/property-2.m | 63 +++++++++++++++ clang/test/SemaObjC/property-3.m | 14 ++++ clang/test/SemaObjC/property-4.m | 30 ++++++++ clang/test/SemaObjC/property-5.m | 31 ++++++++ clang/test/SemaObjC/property-6.m | 69 +++++++++++++++++ clang/test/SemaObjC/property-7.m | 34 +++++++++ clang/test/SemaObjC/property-8.m | 74 ++++++++++++++++++ clang/test/SemaObjC/property-9-impl-method.m | 63 +++++++++++++++ clang/test/SemaObjC/props-on-prots.m | 65 ++++++++++++++++ clang/test/SemaObjC/protocol-archane.m | 14 ++++ clang/test/SemaObjC/string.m | 15 ++++ clang/test/SemaObjC/synchronized.m | 75 ++++++++++++++++++ clang/test/SemaObjC/try-catch.m | 37 +++++++++ clang/test/SemaObjC/typedef-class.m | 78 +++++++++++++++++++ clang/test/SemaObjC/unused.m | 18 +++++ 66 files changed, 1353 insertions(+), 1353 deletions(-) create mode 100644 clang/test/SemaObjC/at-defs.m create mode 100644 clang/test/SemaObjC/bad-receiver-1.m create mode 100644 clang/test/SemaObjC/comptypes-1.m create mode 100644 clang/test/SemaObjC/comptypes-2.m create mode 100644 clang/test/SemaObjC/comptypes-3.m create mode 100644 clang/test/SemaObjC/comptypes-4.m create mode 100644 clang/test/SemaObjC/comptypes-5.m create mode 100644 clang/test/SemaObjC/comptypes-6.m create mode 100644 clang/test/SemaObjC/comptypes-7.m create mode 100644 clang/test/SemaObjC/comptypes-8.m create mode 100644 clang/test/SemaObjC/comptypes-9.m create mode 100644 clang/test/SemaObjC/comptypes-a.m create mode 100644 clang/test/SemaObjC/interface-1.m create mode 100644 clang/test/SemaObjC/interface-layout.m create mode 100644 clang/test/SemaObjC/ivar-lookup.m create mode 100644 clang/test/SemaObjC/legacy-implementation-1.m create mode 100644 clang/test/SemaObjC/method-lookup-2.m delete mode 100644 clang/test/SemaObjC/objc-at-defs.m delete mode 100644 clang/test/SemaObjC/objc-bad-receiver-1.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-1.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-2.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-3.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-4.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-5.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-6.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-7.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-8.m delete mode 100644 clang/test/SemaObjC/objc-comptypes-9.m delete mode 100644 clang/test/SemaObjC/objc-interface-1.m delete mode 100644 clang/test/SemaObjC/objc-interface-layout.m delete mode 100644 clang/test/SemaObjC/objc-ivar-lookup.m delete mode 100644 clang/test/SemaObjC/objc-legacy-implementation-1.m delete mode 100644 clang/test/SemaObjC/objc-method-lookup.m delete mode 100644 clang/test/SemaObjC/objc-property-1.m delete mode 100644 clang/test/SemaObjC/objc-property-2.m delete mode 100644 clang/test/SemaObjC/objc-property-3.m delete mode 100644 clang/test/SemaObjC/objc-property-4.m delete mode 100644 clang/test/SemaObjC/objc-property-5.m delete mode 100644 clang/test/SemaObjC/objc-property-6.m delete mode 100644 clang/test/SemaObjC/objc-property-7.m delete mode 100644 clang/test/SemaObjC/objc-property-8.m delete mode 100644 clang/test/SemaObjC/objc-property-9-impl-method.m delete mode 100644 clang/test/SemaObjC/objc-props-on-prots.m delete mode 100644 clang/test/SemaObjC/objc-protocol-1.m delete mode 100644 clang/test/SemaObjC/objc-string.m delete mode 100644 clang/test/SemaObjC/objc-synchronized.m delete mode 100644 clang/test/SemaObjC/objc-try-catch.m delete mode 100644 clang/test/SemaObjC/objc-typedef-class.m delete mode 100644 clang/test/SemaObjC/objc-types-compatible.m delete mode 100644 clang/test/SemaObjC/objc-unused.m create mode 100644 clang/test/SemaObjC/property-1.m create mode 100644 clang/test/SemaObjC/property-2.m create mode 100644 clang/test/SemaObjC/property-3.m create mode 100644 clang/test/SemaObjC/property-4.m create mode 100644 clang/test/SemaObjC/property-5.m create mode 100644 clang/test/SemaObjC/property-6.m create mode 100644 clang/test/SemaObjC/property-7.m create mode 100644 clang/test/SemaObjC/property-8.m create mode 100644 clang/test/SemaObjC/property-9-impl-method.m create mode 100644 clang/test/SemaObjC/props-on-prots.m create mode 100644 clang/test/SemaObjC/protocol-archane.m create mode 100644 clang/test/SemaObjC/string.m create mode 100644 clang/test/SemaObjC/synchronized.m create mode 100644 clang/test/SemaObjC/try-catch.m create mode 100644 clang/test/SemaObjC/typedef-class.m create mode 100644 clang/test/SemaObjC/unused.m (limited to 'clang/test') diff --git a/clang/test/SemaObjC/at-defs.m b/clang/test/SemaObjC/at-defs.m new file mode 100644 index 00000000000..5bbdd6a715e --- /dev/null +++ b/clang/test/SemaObjC/at-defs.m @@ -0,0 +1,29 @@ +// RUN: clang %s -fsyntax-only + +@interface Test { + double a; +} +@end +@implementation Test +@end +@interface TestObject : Test { +@public + float bar; + int foo; +} +@end +@implementation TestObject +@end +struct wibble { + @defs(TestObject) +}; + + +int main(void) +{ + TestObject * a = (id)malloc(100); + a->foo = 12; + printf("12: %d\n", ((struct wibble*)a)->foo); + printf("%d: %d\n", ((char*)&(((struct wibble*)a)->foo)) - (char*)a, ((char*)&(a->foo)) - (char*)a); + return 0; +} diff --git a/clang/test/SemaObjC/bad-receiver-1.m b/clang/test/SemaObjC/bad-receiver-1.m new file mode 100644 index 00000000000..8376a5ced7a --- /dev/null +++ b/clang/test/SemaObjC/bad-receiver-1.m @@ -0,0 +1,9 @@ +// RUN: clang -fsyntax-only -verify %s + +@interface I +- (id) retain; +@end + +void __raiseExc1() { + [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type 'int'" }} +} diff --git a/clang/test/SemaObjC/comptypes-1.m b/clang/test/SemaObjC/comptypes-1.m new file mode 100644 index 00000000000..e47bc63565f --- /dev/null +++ b/clang/test/SemaObjC/comptypes-1.m @@ -0,0 +1,89 @@ +// RUN: clang -fsyntax-only -verify -pedantic %s + +#define nil (void *)0; +#define Nil (void *)0; + +extern void foo(); + +@protocol MyProtocol +- (void) foo; +@end + +@interface MyClass +@end + +@interface MyOtherClass +- (void) foo; +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_c = nil; + MyOtherClass *obj_cp = nil; + Class obj_C = Nil; + + /* Assigning to an 'id' variable should never + generate a warning. */ + obj = obj_p; /* Ok */ + obj = obj_c; /* Ok */ + obj = obj_cp; /* Ok */ + obj = obj_C; /* Ok */ + + /* Assigning to a 'MyClass *' variable should always generate a + warning, unless done from an 'id'. */ + obj_c = obj; /* Ok */ + obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning 'MyOtherClass *', expected 'MyClass *'}} + obj_c = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyClass *'}} + + /* Assigning to an 'id' variable should generate a + warning if done from a 'MyClass *' (which doesn't implement + MyProtocol), but not from an 'id' or from a 'MyOtherClass *' + (which implements MyProtocol). */ + obj_p = obj; /* Ok */ + obj_p = obj_c; // expected-error {{incompatible type assigning 'MyClass *', expected 'id'}} + obj_p = obj_cp; /* Ok */ + obj_p = obj_C; // expected-error {{incompatible type assigning 'Class', expected 'id'}} + + /* Assigning to a 'MyOtherClass *' variable should always generate + a warning, unless done from an 'id' or an 'id' (since + MyOtherClass implements MyProtocol). */ + obj_cp = obj; /* Ok */ + obj_cp = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'MyOtherClass *'}} + obj_cp = obj_p; /* Ok */ + obj_cp = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyOtherClass *'}} + + /* Any comparison involving an 'id' must be without warnings. */ + if (obj == obj_p) foo() ; /* Ok */ /*Bogus warning here in 2.95.4*/ + if (obj_p == obj) foo() ; /* Ok */ + if (obj == obj_c) foo() ; /* Ok */ + if (obj_c == obj) foo() ; /* Ok */ + if (obj == obj_cp) foo() ; /* Ok */ + if (obj_cp == obj) foo() ; /* Ok */ + if (obj == obj_C) foo() ; /* Ok */ + if (obj_C == obj) foo() ; /* Ok */ + + /* Any comparison between 'MyClass *' and anything which is not an 'id' + must generate a warning. */ + if (obj_p == obj_c) foo() ; // expected-error {{invalid operands to binary expression ('id' 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 *')}} + + if (obj_c == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'Class')}} + if (obj_C == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'MyClass *')}} + + /* Any comparison between 'MyOtherClass *' (which implements + MyProtocol) and an 'id' implementing MyProtocol are Ok. */ + if (obj_cp == obj_p) foo() ; /* Ok */ + if (obj_p == obj_cp) foo() ; /* Ok */ + + + if (obj_p == obj_C) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'Class')}} + if (obj_C == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('Class' and 'id')}} + if (obj_cp == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('MyOtherClass *' and 'Class')}} + if (obj_C == obj_cp) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'MyOtherClass *')}} + + return 0; +} diff --git a/clang/test/SemaObjC/comptypes-2.m b/clang/test/SemaObjC/comptypes-2.m new file mode 100644 index 00000000000..d063d95cc24 --- /dev/null +++ b/clang/test/SemaObjC/comptypes-2.m @@ -0,0 +1,37 @@ +// RUN: clang -fsyntax-only -verify %s + +#define nil (void *)0; +#define Nil (void *)0; + +@protocol MyProtocol +- (void) foo; +@end + +@interface MyClass +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_c = nil; + Class obj_C = Nil; + + /* All these casts should generate no warnings. */ + + obj = (id)obj_p; + obj = (id)obj_c; + obj = (id)obj_C; + obj_c = (MyClass *)obj; + obj_c = (MyClass *)obj_p; + obj_c = (MyClass *)obj_C; + obj_p = (id)obj; + obj_p = (id)obj_c; + obj_p = (id)obj_C; + obj_C = (Class)obj; + obj_C = (Class)obj_p; + obj_C = (Class)obj_c; + + + return 0; +} diff --git a/clang/test/SemaObjC/comptypes-3.m b/clang/test/SemaObjC/comptypes-3.m new file mode 100644 index 00000000000..1e271c8340e --- /dev/null +++ b/clang/test/SemaObjC/comptypes-3.m @@ -0,0 +1,64 @@ +// RUN: clang -fsyntax-only -verify %s + +#define nil (void *)0; + +extern void foo(); + +@protocol MyProtocolA +- (void) methodA; +@end + +@protocol MyProtocolB +- (void) methodB; +@end + +@protocol MyProtocolAB +@end + +@protocol MyProtocolAC +- (void) methodC; +@end + +int main() +{ + id obj_a = nil; + id obj_b = nil; + id obj_ab = nil; + id obj_ac = nil; + + obj_a = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_a = obj_ab; /* Ok */ + obj_a = obj_ac; /* Ok */ + + obj_b = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_b = obj_ab; /* Ok */ + obj_b = obj_ac; // expected-error {{incompatible type assigning 'id', expected 'id'}} + + obj_ab = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_ab = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_ab = obj_ac; // expected-error {{incompatible type assigning 'id', expected 'id'}} + + obj_ac = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_ac = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} + obj_ac = obj_ab; // expected-error {{incompatible type assigning 'id', expected 'id'}} + + if (obj_a == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_b == obj_a) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + if (obj_a == obj_ab) foo (); /* Ok */ + if (obj_ab == obj_a) foo (); /* Ok */ + + if (obj_a == obj_ac) foo (); /* Ok */ + if (obj_ac == obj_a) foo (); /* Ok */ + + if (obj_b == obj_ab) foo (); /* Ok */ + if (obj_ab == obj_b) foo (); /* Ok */ + + if (obj_b == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_ac == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + if (obj_ab == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + if (obj_ac == obj_ab) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} + + return 0; +} diff --git a/clang/test/SemaObjC/comptypes-4.m b/clang/test/SemaObjC/comptypes-4.m new file mode 100644 index 00000000000..bda9050164b --- /dev/null +++ b/clang/test/SemaObjC/comptypes-4.m @@ -0,0 +1,25 @@ +// RUN: clang -fsyntax-only -verify %s + +extern void foo(); + +@protocol MyProtocol @end + +@interface MyClass @end + +int main() +{ + MyClass *obj_p; + MyClass *obj_cp; + + obj_cp = obj_p; + obj_p = obj_cp; + + if (obj_cp == obj_p) + foo(); + + if (obj_p == obj_cp) + foo(); + +} + + diff --git a/clang/test/SemaObjC/comptypes-5.m b/clang/test/SemaObjC/comptypes-5.m new file mode 100644 index 00000000000..f12fa9ab5d4 --- /dev/null +++ b/clang/test/SemaObjC/comptypes-5.m @@ -0,0 +1,44 @@ +// RUN: clang -fsyntax-only -pedantic -verify %s + +#define nil (void *)0; + +extern void foo(); + +@protocol MyProtocol +- (void) method; +@end + +@interface MyClass +@end + +@interface MyClass (Addition) +- (void) method; +@end + +@interface MyOtherClass : MyClass +@end + +int main() +{ + id obj_id_p = nil; + MyClass *obj_c_cat_p = nil; + MyOtherClass *obj_c_super_p = nil; + MyOtherClass *obj_c_super_p_q = nil; + MyClass *obj_c_cat_p_q = nil; + + obj_c_cat_p = obj_id_p; // expected-error {{incompatible type assigning 'id', expected 'MyClass *'}} + obj_c_super_p = obj_id_p; // expected-error {{incompatible type assigning 'id', expected 'MyOtherClass *'}} + obj_id_p = obj_c_cat_p; /* Ok */ + obj_id_p = obj_c_super_p; /* Ok */ + + if (obj_c_cat_p == obj_id_p) foo(); /* Ok */ + if (obj_c_super_p == obj_id_p) foo() ; /* Ok */ + if (obj_id_p == obj_c_cat_p) foo(); /* Ok */ + if (obj_id_p == obj_c_super_p) foo(); /* Ok */ + + obj_c_cat_p = obj_c_super_p; // ok. + obj_c_cat_p = obj_c_super_p_q; // ok. + obj_c_super_p = obj_c_cat_p_q; // expected-warning {{incompatible pointer types}} + obj_c_cat_p_q = obj_c_super_p; + return 0; +} diff --git a/clang/test/SemaObjC/comptypes-6.m b/clang/test/SemaObjC/comptypes-6.m new file mode 100644 index 00000000000..2edb181e83b --- /dev/null +++ b/clang/test/SemaObjC/comptypes-6.m @@ -0,0 +1,16 @@ +// RUN: clang -fsyntax-only -verify -pedantic %s + +@interface Derived +@end + +@interface Object @end + +extern Object* foo(void); + +static Derived *test(void) +{ + Derived *m = foo(); // expected-warning {{incompatible pointer types initializing 'Object *', expected 'Derived *'}} + + return m; +} + diff --git a/clang/test/SemaObjC/comptypes-7.m b/clang/test/SemaObjC/comptypes-7.m new file mode 100644 index 00000000000..ef3a7790a3d --- /dev/null +++ b/clang/test/SemaObjC/comptypes-7.m @@ -0,0 +1,70 @@ +// RUN: clang -fsyntax-only -verify -pedantic %s + +#define nil (void *)0; +#define Nil (void *)0; + +extern void foo(); + +@protocol MyProtocol +- (void) method; +@end + +@interface MyClass +@end + +int main() +{ + id obj = nil; + id obj_p = nil; + MyClass *obj_c = nil; + Class obj_C = Nil; + + int i = 0; + int *j = nil; + + /* These should all generate warnings. */ + + obj = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'id'}} + 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'}} + obj_p = j; // expected-error {{incompatible type assigning 'int *', expected 'id'}} + + 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 *'}} + + obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'Class'}} + obj_C = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'Class'}} + + i = obj; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} + i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} + i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning 'MyClass *', expected 'int'}} + 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-error {{incompatible type assigning 'id', 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 *'}} + + if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}} + if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}} + if (obj == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id' and 'int *')}} + if (j == obj) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id')}} + + if (obj_c == i) foo() ; // expected-warning {{comparison between pointer and integer ('MyClass *' and 'int')}} + if (i == obj_c) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'MyClass *')}} + if (obj_c == j) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'int *')}} + if (j == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'MyClass *')}} + + if (obj_p == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}} + if (i == obj_p) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}} + if (obj_p == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}} + if (j == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}} + + if (obj_C == i) foo() ; // expected-warning {{comparison between pointer and integer ('Class' and 'int')}} + if (i == obj_C) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'Class')}} + if (obj_C == j) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'int *')}} + if (j == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'Class')}} + + return 0; +} diff --git a/clang/test/SemaObjC/comptypes-8.m b/clang/test/SemaObjC/comptypes-8.m new file mode 100644 index 00000000000..c22e88c8805 --- /dev/null +++ b/clang/test/SemaObjC/comptypes-8.m @@ -0,0 +1,12 @@ +// RUN: clang -fsyntax-only %s + +@protocol MyProtocol +@end + +id obj_p = 0; + +int main() +{ + obj_p = 0; +} + diff --git a/clang/test/SemaObjC/comptypes-9.m b/clang/test/SemaObjC/comptypes-9.m new file mode 100644 index 00000000000..4f0a277e74e --- /dev/null +++ b/clang/test/SemaObjC/comptypes-9.m @@ -0,0 +1,86 @@ +// RUN: clang -fsyntax-only %s +// FIXME: This test case tests the patch applied in: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080602/006017.html +// Eventually that logic should be treated as an extension. + +typedef signed char BOOL; +typedef int NSInteger; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@protocol NSMutableCopying +- (id)mutableCopyWithZone:(NSZone *)zone; +@end + +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end + +@interface NSObject {} +@end + +@class NSArray; + +typedef struct {} NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end + +@class NSString; + +@interface NSArray : NSObject +- (NSUInteger)count; +- (id)objectAtIndex:(NSUInteger)index; +@end + +typedef unsigned short unichar; + +@interface NSString : NSObject +- (NSUInteger)length; +@end + +@interface NSSimpleCString : NSString +{} + +@end + +@interface NSConstantString : NSSimpleCString @end + +extern void *_NSConstantStringClassReference; + +@interface NSResponder : NSObject {} +@end + +@class NSDate, NSDictionary, NSError, NSException, NSNotification; + +@interface NSWindowController : NSResponder {} +@end + +@class PBXBuildLog, PBXBuildLogItem, PBXBuildLogContainerItem, XCWorkQueueCommand, XCBuildLogContainerItemMutationState; + +@protocol PBXBuildLogContainerItems +- (PBXBuildLog *)buildLog; +@end + +@interface PBXBuildLogItem : NSObject {} +- (id )superitem; +@end +@interface PBXBuildResultsModule +@end + +@implementation PBXBuildResultsModule +- (void) revealItems +{ + PBXBuildLogItem *objItem; + PBXBuildLogItem *superitem = [objItem superitem]; +} +@end diff --git a/clang/test/SemaObjC/comptypes-a.m b/clang/test/SemaObjC/comptypes-a.m new file mode 100644 index 00000000000..bd8a7490c41 --- /dev/null +++ b/clang/test/SemaObjC/comptypes-a.m @@ -0,0 +1,40 @@ +// RUN: clang -fsyntax-only -verify -pedantic %s +typedef signed char BOOL; +typedef int NSInteger; + +@class NSString; + +@protocol PBXCompletionItem +- (NSString *) name; +- (NSInteger)priority; +@end + +extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context); + +NSInteger codeAssistantCaseCompareItems(id a, id b, void *context) +{ +} + +#if 0 +FIXME: clang needs to compare each method prototype with its definition (see below). + +GCC produces the following correct warnning: +[snaroff:llvm/tools/clang] snarofflocal% cc -c test/Sema/objc-types-compatible.m +test/Sema/objc-types-compatible.m: In function ‘-[TedWantsToVerifyObjCDoesTheRightThing compareThis:withThat:]’: +test/Sema/objc-types-compatible.m:26: warning: conflicting types for ‘-(id)compareThis:(id )a withThat:(id )b’ +test/Sema/objc-types-compatible.m:20: warning: previous declaration of ‘-(id)compareThis:(int)a withThat:(id)b’ +#endif + +@interface TedWantsToVerifyObjCDoesTheRightThing + +- compareThis:(int)a withThat:(id)b; + +@end + +@implementation TedWantsToVerifyObjCDoesTheRightThing + +- compareThis:(id)a withThat:(id)b { + return self; +} + +@end diff --git a/clang/test/SemaObjC/interface-1.m b/clang/test/SemaObjC/interface-1.m new file mode 100644 index 00000000000..0130a33f9b9 --- /dev/null +++ b/clang/test/SemaObjC/interface-1.m @@ -0,0 +1,17 @@ +// RUN: clang %s -fsyntax-only -verify +// rdar://5957506 + +@interface NSWhatever : +NSObject // expected-error {{cannot find interface declaration for 'NSObject'}} + // expected-error {{cannot find protocol definition for 'NSCopying'}} +@end + + +// rdar://6095245 +@interface A +{ + int x +} // expected-error {{expected ';' at end of declaration list}} +@end + + diff --git a/clang/test/SemaObjC/interface-layout.m b/clang/test/SemaObjC/interface-layout.m new file mode 100644 index 00000000000..637de8e3ac6 --- /dev/null +++ b/clang/test/SemaObjC/interface-layout.m @@ -0,0 +1,27 @@ +// RUN: clang %s -fsyntax-only -verify +typedef struct objc_object {} *id; +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; + +@protocol NSObject +- (BOOL) isEqual:(id) object; +@end + +@protocol NSCopying +- (id) copyWithZone:(NSZone *) zone; +@end + +@interface NSObject < NSObject > {} +@end + +extern id NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone * zone); + +@interface MyClassBase : NSObject < NSCopying > {} +@end + +@interface MyClassDirectNode : MyClassBase < NSCopying > +{ + @public NSUInteger attributeRuns[((1024 - 16 - sizeof (MyClassBase)) / (sizeof (NSUInteger) + sizeof (void *)))]; +} +@end diff --git a/clang/test/SemaObjC/ivar-lookup.m b/clang/test/SemaObjC/ivar-lookup.m new file mode 100644 index 00000000000..e599e9da016 --- /dev/null +++ b/clang/test/SemaObjC/ivar-lookup.m @@ -0,0 +1,18 @@ +// RUN: clang %s -fsyntax-only -verify + +@interface Test { + int x; +} + +-(void) setX: (int) d; +@end + +extern struct foo x; + +@implementation Test + +-(void) setX: (int) n { + x = n; +} + +@end diff --git a/clang/test/SemaObjC/legacy-implementation-1.m b/clang/test/SemaObjC/legacy-implementation-1.m new file mode 100644 index 00000000000..76434471d14 --- /dev/null +++ b/clang/test/SemaObjC/legacy-implementation-1.m @@ -0,0 +1,11 @@ +// RUN: clang -fsyntax-only -verify %s + +@implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}} +@end + +INTF* pi; + +INTF* FUNC() +{ + return pi; +} diff --git a/clang/test/SemaObjC/method-lookup-2.m b/clang/test/SemaObjC/method-lookup-2.m new file mode 100644 index 00000000000..4ebdb8e4524 --- /dev/null +++ b/clang/test/SemaObjC/method-lookup-2.m @@ -0,0 +1,40 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; + +@protocol NSObject +- (BOOL) isEqual:(id) object; +@end + +@interface NSObject < NSObject > {} @end + +@class NSString, NSPort; + +@interface NSPortNameServer:NSObject ++ (NSPortNameServer *) systemDefaultPortNameServer; +@end + +@interface NSMachBootstrapServer:NSPortNameServer + (id) sharedInstance; @end + +enum { + NSWindowsNTOperatingSystem = 1, NSWindows95OperatingSystem, NSSolarisOperatingSystem, NSHPUXOperatingSystem, NSMACHOperatingSystem, NSSunOSOperatingSystem, NSOSF1OperatingSystem +}; + +@interface NSRunLoop:NSObject {} @end + +@interface NSRunLoop(NSRunLoopConveniences) +- (void) run; +@end + +extern NSString *const NSWillBecomeMultiThreadedNotification; + +@interface SenTestTool:NSObject {} +@end + +@implementation SenTestTool ++ (void) initialize {} ++(SenTestTool *) sharedInstance {} +-(int) run {} ++(int) run { + return[[self sharedInstance] run]; +} +@end diff --git a/clang/test/SemaObjC/objc-at-defs.m b/clang/test/SemaObjC/objc-at-defs.m deleted file mode 100644 index 5bbdd6a715e..00000000000 --- a/clang/test/SemaObjC/objc-at-defs.m +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: clang %s -fsyntax-only - -@interface Test { - double a; -} -@end -@implementation Test -@end -@interface TestObject : Test { -@public - float bar; - int foo; -} -@end -@implementation TestObject -@end -struct wibble { - @defs(TestObject) -}; - - -int main(void) -{ - TestObject * a = (id)malloc(100); - a->foo = 12; - printf("12: %d\n", ((struct wibble*)a)->foo); - printf("%d: %d\n", ((char*)&(((struct wibble*)a)->foo)) - (char*)a, ((char*)&(a->foo)) - (char*)a); - return 0; -} diff --git a/clang/test/SemaObjC/objc-bad-receiver-1.m b/clang/test/SemaObjC/objc-bad-receiver-1.m deleted file mode 100644 index 8376a5ced7a..00000000000 --- a/clang/test/SemaObjC/objc-bad-receiver-1.m +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -@interface I -- (id) retain; -@end - -void __raiseExc1() { - [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type 'int'" }} -} diff --git a/clang/test/SemaObjC/objc-comptypes-1.m b/clang/test/SemaObjC/objc-comptypes-1.m deleted file mode 100644 index e47bc63565f..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-1.m +++ /dev/null @@ -1,89 +0,0 @@ -// RUN: clang -fsyntax-only -verify -pedantic %s - -#define nil (void *)0; -#define Nil (void *)0; - -extern void foo(); - -@protocol MyProtocol -- (void) foo; -@end - -@interface MyClass -@end - -@interface MyOtherClass -- (void) foo; -@end - -int main() -{ - id obj = nil; - id obj_p = nil; - MyClass *obj_c = nil; - MyOtherClass *obj_cp = nil; - Class obj_C = Nil; - - /* Assigning to an 'id' variable should never - generate a warning. */ - obj = obj_p; /* Ok */ - obj = obj_c; /* Ok */ - obj = obj_cp; /* Ok */ - obj = obj_C; /* Ok */ - - /* Assigning to a 'MyClass *' variable should always generate a - warning, unless done from an 'id'. */ - obj_c = obj; /* Ok */ - obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning 'MyOtherClass *', expected 'MyClass *'}} - obj_c = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyClass *'}} - - /* Assigning to an 'id' variable should generate a - warning if done from a 'MyClass *' (which doesn't implement - MyProtocol), but not from an 'id' or from a 'MyOtherClass *' - (which implements MyProtocol). */ - obj_p = obj; /* Ok */ - obj_p = obj_c; // expected-error {{incompatible type assigning 'MyClass *', expected 'id'}} - obj_p = obj_cp; /* Ok */ - obj_p = obj_C; // expected-error {{incompatible type assigning 'Class', expected 'id'}} - - /* Assigning to a 'MyOtherClass *' variable should always generate - a warning, unless done from an 'id' or an 'id' (since - MyOtherClass implements MyProtocol). */ - obj_cp = obj; /* Ok */ - obj_cp = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'MyOtherClass *'}} - obj_cp = obj_p; /* Ok */ - obj_cp = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyOtherClass *'}} - - /* Any comparison involving an 'id' must be without warnings. */ - if (obj == obj_p) foo() ; /* Ok */ /*Bogus warning here in 2.95.4*/ - if (obj_p == obj) foo() ; /* Ok */ - if (obj == obj_c) foo() ; /* Ok */ - if (obj_c == obj) foo() ; /* Ok */ - if (obj == obj_cp) foo() ; /* Ok */ - if (obj_cp == obj) foo() ; /* Ok */ - if (obj == obj_C) foo() ; /* Ok */ - if (obj_C == obj) foo() ; /* Ok */ - - /* Any comparison between 'MyClass *' and anything which is not an 'id' - must generate a warning. */ - if (obj_p == obj_c) foo() ; // expected-error {{invalid operands to binary expression ('id' 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 *')}} - - if (obj_c == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'Class')}} - if (obj_C == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'MyClass *')}} - - /* Any comparison between 'MyOtherClass *' (which implements - MyProtocol) and an 'id' implementing MyProtocol are Ok. */ - if (obj_cp == obj_p) foo() ; /* Ok */ - if (obj_p == obj_cp) foo() ; /* Ok */ - - - if (obj_p == obj_C) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'Class')}} - if (obj_C == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('Class' and 'id')}} - if (obj_cp == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('MyOtherClass *' and 'Class')}} - if (obj_C == obj_cp) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'MyOtherClass *')}} - - return 0; -} diff --git a/clang/test/SemaObjC/objc-comptypes-2.m b/clang/test/SemaObjC/objc-comptypes-2.m deleted file mode 100644 index d063d95cc24..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-2.m +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -#define nil (void *)0; -#define Nil (void *)0; - -@protocol MyProtocol -- (void) foo; -@end - -@interface MyClass -@end - -int main() -{ - id obj = nil; - id obj_p = nil; - MyClass *obj_c = nil; - Class obj_C = Nil; - - /* All these casts should generate no warnings. */ - - obj = (id)obj_p; - obj = (id)obj_c; - obj = (id)obj_C; - obj_c = (MyClass *)obj; - obj_c = (MyClass *)obj_p; - obj_c = (MyClass *)obj_C; - obj_p = (id)obj; - obj_p = (id)obj_c; - obj_p = (id)obj_C; - obj_C = (Class)obj; - obj_C = (Class)obj_p; - obj_C = (Class)obj_c; - - - return 0; -} diff --git a/clang/test/SemaObjC/objc-comptypes-3.m b/clang/test/SemaObjC/objc-comptypes-3.m deleted file mode 100644 index 1e271c8340e..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-3.m +++ /dev/null @@ -1,64 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -#define nil (void *)0; - -extern void foo(); - -@protocol MyProtocolA -- (void) methodA; -@end - -@protocol MyProtocolB -- (void) methodB; -@end - -@protocol MyProtocolAB -@end - -@protocol MyProtocolAC -- (void) methodC; -@end - -int main() -{ - id obj_a = nil; - id obj_b = nil; - id obj_ab = nil; - id obj_ac = nil; - - obj_a = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_a = obj_ab; /* Ok */ - obj_a = obj_ac; /* Ok */ - - obj_b = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_b = obj_ab; /* Ok */ - obj_b = obj_ac; // expected-error {{incompatible type assigning 'id', expected 'id'}} - - obj_ab = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_ab = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_ab = obj_ac; // expected-error {{incompatible type assigning 'id', expected 'id'}} - - obj_ac = obj_a; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_ac = obj_b; // expected-error {{incompatible type assigning 'id', expected 'id'}} - obj_ac = obj_ab; // expected-error {{incompatible type assigning 'id', expected 'id'}} - - if (obj_a == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - if (obj_b == obj_a) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - - if (obj_a == obj_ab) foo (); /* Ok */ - if (obj_ab == obj_a) foo (); /* Ok */ - - if (obj_a == obj_ac) foo (); /* Ok */ - if (obj_ac == obj_a) foo (); /* Ok */ - - if (obj_b == obj_ab) foo (); /* Ok */ - if (obj_ab == obj_b) foo (); /* Ok */ - - if (obj_b == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - if (obj_ac == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - - if (obj_ab == obj_ac) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - if (obj_ac == obj_ab) foo (); // expected-error {{invalid operands to binary expression ('id' and 'id')}} - - return 0; -} diff --git a/clang/test/SemaObjC/objc-comptypes-4.m b/clang/test/SemaObjC/objc-comptypes-4.m deleted file mode 100644 index bda9050164b..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-4.m +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -extern void foo(); - -@protocol MyProtocol @end - -@interface MyClass @end - -int main() -{ - MyClass *obj_p; - MyClass *obj_cp; - - obj_cp = obj_p; - obj_p = obj_cp; - - if (obj_cp == obj_p) - foo(); - - if (obj_p == obj_cp) - foo(); - -} - - diff --git a/clang/test/SemaObjC/objc-comptypes-5.m b/clang/test/SemaObjC/objc-comptypes-5.m deleted file mode 100644 index f12fa9ab5d4..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-5.m +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: clang -fsyntax-only -pedantic -verify %s - -#define nil (void *)0; - -extern void foo(); - -@protocol MyProtocol -- (void) method; -@end - -@interface MyClass -@end - -@interface MyClass (Addition) -- (void) method; -@end - -@interface MyOtherClass : MyClass -@end - -int main() -{ - id obj_id_p = nil; - MyClass *obj_c_cat_p = nil; - MyOtherClass *obj_c_super_p = nil; - MyOtherClass *obj_c_super_p_q = nil; - MyClass *obj_c_cat_p_q = nil; - - obj_c_cat_p = obj_id_p; // expected-error {{incompatible type assigning 'id', expected 'MyClass *'}} - obj_c_super_p = obj_id_p; // expected-error {{incompatible type assigning 'id', expected 'MyOtherClass *'}} - obj_id_p = obj_c_cat_p; /* Ok */ - obj_id_p = obj_c_super_p; /* Ok */ - - if (obj_c_cat_p == obj_id_p) foo(); /* Ok */ - if (obj_c_super_p == obj_id_p) foo() ; /* Ok */ - if (obj_id_p == obj_c_cat_p) foo(); /* Ok */ - if (obj_id_p == obj_c_super_p) foo(); /* Ok */ - - obj_c_cat_p = obj_c_super_p; // ok. - obj_c_cat_p = obj_c_super_p_q; // ok. - obj_c_super_p = obj_c_cat_p_q; // expected-warning {{incompatible pointer types}} - obj_c_cat_p_q = obj_c_super_p; - return 0; -} diff --git a/clang/test/SemaObjC/objc-comptypes-6.m b/clang/test/SemaObjC/objc-comptypes-6.m deleted file mode 100644 index 2edb181e83b..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-6.m +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: clang -fsyntax-only -verify -pedantic %s - -@interface Derived -@end - -@interface Object @end - -extern Object* foo(void); - -static Derived *test(void) -{ - Derived *m = foo(); // expected-warning {{incompatible pointer types initializing 'Object *', expected 'Derived *'}} - - return m; -} - diff --git a/clang/test/SemaObjC/objc-comptypes-7.m b/clang/test/SemaObjC/objc-comptypes-7.m deleted file mode 100644 index ef3a7790a3d..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-7.m +++ /dev/null @@ -1,70 +0,0 @@ -// RUN: clang -fsyntax-only -verify -pedantic %s - -#define nil (void *)0; -#define Nil (void *)0; - -extern void foo(); - -@protocol MyProtocol -- (void) method; -@end - -@interface MyClass -@end - -int main() -{ - id obj = nil; - id obj_p = nil; - MyClass *obj_c = nil; - Class obj_C = Nil; - - int i = 0; - int *j = nil; - - /* These should all generate warnings. */ - - obj = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'id'}} - 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'}} - obj_p = j; // expected-error {{incompatible type assigning 'int *', expected 'id'}} - - 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 *'}} - - obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning 'int', expected 'Class'}} - obj_C = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'Class'}} - - i = obj; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} - i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning 'id', expected 'int'}} - i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning 'MyClass *', expected 'int'}} - 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-error {{incompatible type assigning 'id', 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 *'}} - - if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}} - if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}} - if (obj == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id' and 'int *')}} - if (j == obj) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id')}} - - if (obj_c == i) foo() ; // expected-warning {{comparison between pointer and integer ('MyClass *' and 'int')}} - if (i == obj_c) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'MyClass *')}} - if (obj_c == j) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'int *')}} - if (j == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'MyClass *')}} - - if (obj_p == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}} - if (i == obj_p) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}} - if (obj_p == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}} - if (j == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}} - - if (obj_C == i) foo() ; // expected-warning {{comparison between pointer and integer ('Class' and 'int')}} - if (i == obj_C) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'Class')}} - if (obj_C == j) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'int *')}} - if (j == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'Class')}} - - return 0; -} diff --git a/clang/test/SemaObjC/objc-comptypes-8.m b/clang/test/SemaObjC/objc-comptypes-8.m deleted file mode 100644 index c22e88c8805..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-8.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: clang -fsyntax-only %s - -@protocol MyProtocol -@end - -id obj_p = 0; - -int main() -{ - obj_p = 0; -} - diff --git a/clang/test/SemaObjC/objc-comptypes-9.m b/clang/test/SemaObjC/objc-comptypes-9.m deleted file mode 100644 index 4f0a277e74e..00000000000 --- a/clang/test/SemaObjC/objc-comptypes-9.m +++ /dev/null @@ -1,86 +0,0 @@ -// RUN: clang -fsyntax-only %s -// FIXME: This test case tests the patch applied in: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080602/006017.html -// Eventually that logic should be treated as an extension. - -typedef signed char BOOL; -typedef int NSInteger; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end - -@protocol NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end - -@interface NSObject {} -@end - -@class NSArray; - -typedef struct {} NSFastEnumerationState; - -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end - -@class NSString; - -@interface NSArray : NSObject -- (NSUInteger)count; -- (id)objectAtIndex:(NSUInteger)index; -@end - -typedef unsigned short unichar; - -@interface NSString : NSObject -- (NSUInteger)length; -@end - -@interface NSSimpleCString : NSString -{} - -@end - -@interface NSConstantString : NSSimpleCString @end - -extern void *_NSConstantStringClassReference; - -@interface NSResponder : NSObject {} -@end - -@class NSDate, NSDictionary, NSError, NSException, NSNotification; - -@interface NSWindowController : NSResponder {} -@end - -@class PBXBuildLog, PBXBuildLogItem, PBXBuildLogContainerItem, XCWorkQueueCommand, XCBuildLogContainerItemMutationState; - -@protocol PBXBuildLogContainerItems -- (PBXBuildLog *)buildLog; -@end - -@interface PBXBuildLogItem : NSObject {} -- (id )superitem; -@end -@interface PBXBuildResultsModule -@end - -@implementation PBXBuildResultsModule -- (void) revealItems -{ - PBXBuildLogItem *objItem; - PBXBuildLogItem *superitem = [objItem superitem]; -} -@end diff --git a/clang/test/SemaObjC/objc-interface-1.m b/clang/test/SemaObjC/objc-interface-1.m deleted file mode 100644 index 0130a33f9b9..00000000000 --- a/clang/test/SemaObjC/objc-interface-1.m +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: clang %s -fsyntax-only -verify -// rdar://5957506 - -@interface NSWhatever : -NSObject // expected-error {{cannot find interface declaration for 'NSObject'}} - // expected-error {{cannot find protocol definition for 'NSCopying'}} -@end - - -// rdar://6095245 -@interface A -{ - int x -} // expected-error {{expected ';' at end of declaration list}} -@end - - diff --git a/clang/test/SemaObjC/objc-interface-layout.m b/clang/test/SemaObjC/objc-interface-layout.m deleted file mode 100644 index 637de8e3ac6..00000000000 --- a/clang/test/SemaObjC/objc-interface-layout.m +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: clang %s -fsyntax-only -verify -typedef struct objc_object {} *id; -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; - -@protocol NSObject -- (BOOL) isEqual:(id) object; -@end - -@protocol NSCopying -- (id) copyWithZone:(NSZone *) zone; -@end - -@interface NSObject < NSObject > {} -@end - -extern id NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone * zone); - -@interface MyClassBase : NSObject < NSCopying > {} -@end - -@interface MyClassDirectNode : MyClassBase < NSCopying > -{ - @public NSUInteger attributeRuns[((1024 - 16 - sizeof (MyClassBase)) / (sizeof (NSUInteger) + sizeof (void *)))]; -} -@end diff --git a/clang/test/SemaObjC/objc-ivar-lookup.m b/clang/test/SemaObjC/objc-ivar-lookup.m deleted file mode 100644 index e599e9da016..00000000000 --- a/clang/test/SemaObjC/objc-ivar-lookup.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: clang %s -fsyntax-only -verify - -@interface Test { - int x; -} - --(void) setX: (int) d; -@end - -extern struct foo x; - -@implementation Test - --(void) setX: (int) n { - x = n; -} - -@end diff --git a/clang/test/SemaObjC/objc-legacy-implementation-1.m b/clang/test/SemaObjC/objc-legacy-implementation-1.m deleted file mode 100644 index 76434471d14..00000000000 --- a/clang/test/SemaObjC/objc-legacy-implementation-1.m +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -@implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}} -@end - -INTF* pi; - -INTF* FUNC() -{ - return pi; -} diff --git a/clang/test/SemaObjC/objc-method-lookup.m b/clang/test/SemaObjC/objc-method-lookup.m deleted file mode 100644 index 4ebdb8e4524..00000000000 --- a/clang/test/SemaObjC/objc-method-lookup.m +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; - -@protocol NSObject -- (BOOL) isEqual:(id) object; -@end - -@interface NSObject < NSObject > {} @end - -@class NSString, NSPort; - -@interface NSPortNameServer:NSObject -+ (NSPortNameServer *) systemDefaultPortNameServer; -@end - -@interface NSMachBootstrapServer:NSPortNameServer + (id) sharedInstance; @end - -enum { - NSWindowsNTOperatingSystem = 1, NSWindows95OperatingSystem, NSSolarisOperatingSystem, NSHPUXOperatingSystem, NSMACHOperatingSystem, NSSunOSOperatingSystem, NSOSF1OperatingSystem -}; - -@interface NSRunLoop:NSObject {} @end - -@interface NSRunLoop(NSRunLoopConveniences) -- (void) run; -@end - -extern NSString *const NSWillBecomeMultiThreadedNotification; - -@interface SenTestTool:NSObject {} -@end - -@implementation SenTestTool -+ (void) initialize {} -+(SenTestTool *) sharedInstance {} --(int) run {} -+(int) run { - return[[self sharedInstance] run]; -} -@end diff --git a/clang/test/SemaObjC/objc-property-1.m b/clang/test/SemaObjC/objc-property-1.m deleted file mode 100644 index 3bc2e3386b0..00000000000 --- a/clang/test/SemaObjC/objc-property-1.m +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -@interface I -{ - int IVAR; - int name; -} -@property int d1; -@property id prop_id; -@property int name; -@end - -@interface I(CAT) -@property int d1; -@end - -@implementation I -@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}} -@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}} -@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} -@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}} -@synthesize name; // OK! property with same name as an accessible ivar of same name -@end - -@implementation I(CAT) -@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 - -@implementation E // expected-warning {{cannot find interface declaration for 'E'}} -@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}} -@end - -@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}} -@dynamic d; // expected-error {{property implementation in a category with no category declaration}} -@end - - - diff --git a/clang/test/SemaObjC/objc-property-2.m b/clang/test/SemaObjC/objc-property-2.m deleted file mode 100644 index 4472a8f6955..00000000000 --- a/clang/test/SemaObjC/objc-property-2.m +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s - -@interface Tester -@property char PropertyAtomic_char; -@property short PropertyAtomic_short; -@property int PropertyAtomic_int; -@property long PropertyAtomic_long; -@property long long PropertyAtomic_longlong; -@property float PropertyAtomic_float; -@property double PropertyAtomic_double; -@property(assign) id PropertyAtomic_id; -@property(retain) id PropertyAtomicRetained_id; -@property(copy) id PropertyAtomicRetainedCopied_id; -@property(retain) id PropertyAtomicRetainedGCOnly_id; -@property(copy) id PropertyAtomicRetainedCopiedGCOnly_id; -@end - -@implementation Tester -@dynamic PropertyAtomic_char; -@dynamic PropertyAtomic_short; -@dynamic PropertyAtomic_int; -@dynamic PropertyAtomic_long; -@dynamic PropertyAtomic_longlong; -@dynamic PropertyAtomic_float; -@dynamic PropertyAtomic_double; -@dynamic PropertyAtomic_id; -@dynamic PropertyAtomicRetained_id; -@dynamic PropertyAtomicRetainedCopied_id; -@dynamic PropertyAtomicRetainedGCOnly_id; -@dynamic PropertyAtomicRetainedCopiedGCOnly_id; -@end - -@interface SubClass : Tester -{ - char PropertyAtomic_char; - short PropertyAtomic_short; - int PropertyAtomic_int; - long PropertyAtomic_long; - long long PropertyAtomic_longlong; - float PropertyAtomic_float; - double PropertyAtomic_double; - id PropertyAtomic_id; - id PropertyAtomicRetained_id; - id PropertyAtomicRetainedCopied_id; - id PropertyAtomicRetainedGCOnly_id; - id PropertyAtomicRetainedCopiedGCOnly_id; -} -@end - -@implementation SubClass -@synthesize PropertyAtomic_char; -@synthesize PropertyAtomic_short; -@synthesize PropertyAtomic_int; -@synthesize PropertyAtomic_long; -@synthesize PropertyAtomic_longlong; -@synthesize PropertyAtomic_float; -@synthesize PropertyAtomic_double; -@synthesize PropertyAtomic_id; -@synthesize PropertyAtomicRetained_id; -@synthesize PropertyAtomicRetainedCopied_id; -@synthesize PropertyAtomicRetainedGCOnly_id; -@synthesize PropertyAtomicRetainedCopiedGCOnly_id; -@end diff --git a/clang/test/SemaObjC/objc-property-3.m b/clang/test/SemaObjC/objc-property-3.m deleted file mode 100644 index b22059c2382..00000000000 --- a/clang/test/SemaObjC/objc-property-3.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: clang -verify %s - -@interface I -{ - id d1; -} -@property (readwrite, copy) id d1; -@property (readwrite, copy) id d2; -@end - -@interface NOW : I -@property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from'I'}} -@property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}} -@end diff --git a/clang/test/SemaObjC/objc-property-4.m b/clang/test/SemaObjC/objc-property-4.m deleted file mode 100644 index b5a8f8b1ccb..00000000000 --- a/clang/test/SemaObjC/objc-property-4.m +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: clang -verify %s - -@interface Object -@end - -@protocol ProtocolObject -@property int class; -@property (copy) id MayCauseError; -@end - -@protocol ProtocolDerivedGCObject -@property int Dclass; -@end - -@interface GCObject : Object { - int ifield; - int iOwnClass; - int iDclass; -} -@property int OwnClass; -@end - -@interface ReleaseObject : GCObject { - int newO; - int oldO; -} -@property (retain) id MayCauseError; // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'GCObject'}} \ - expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'ProtocolObject'}} -@end - diff --git a/clang/test/SemaObjC/objc-property-5.m b/clang/test/SemaObjC/objc-property-5.m deleted file mode 100644 index c467e634dcc..00000000000 --- a/clang/test/SemaObjC/objc-property-5.m +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: clang -verify %s - -@protocol P1 @end -@protocol P2 @end -@protocol P3 @end - -@interface NSData @end - -@interface MutableNSData : NSData @end - -@interface Base : NSData -@property(readonly) id ref; -@property(readonly) Base *p_base; -@property(readonly) NSData *nsdata; -@property(readonly) NSData * m_nsdata; -@end - -@interface Data : Base -@property(readonly) NSData *ref; // expected-warning {{property type 'NSData *' does not match property type inherited from 'Base'}} -@property(readonly) Data *p_base; // expected-warning {{property type 'Data *' does not match property type inherited from 'Base'}} -@property(readonly) MutableNSData * m_nsdata; // expected-warning {{property type 'MutableNSData *' does not match property type inherited from 'Base'}} -@end - -@interface MutedData: Data -@property(readonly) id p_base; // expected-warning {{property type 'id' does not match property type inherited from 'Data'}} -@end - -@interface ConstData : Data -@property(readonly) ConstData *p_base; // expected-warning {{property type 'ConstData *' does not match property type inherited from 'Data'}} -@end - diff --git a/clang/test/SemaObjC/objc-property-6.m b/clang/test/SemaObjC/objc-property-6.m deleted file mode 100644 index a51994d3d49..00000000000 --- a/clang/test/SemaObjC/objc-property-6.m +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -# 1 "" -# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3 -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; - -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -+ class; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end - -@protocol NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end - -@interface NSObject {} -@end - -typedef struct {} NSFastEnumerationState; - -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end - -@interface NSArray : NSObject -- (NSUInteger)count; -@end - -@interface NSMutableArray : NSArray -- (void)addObject:(id)anObject; -+ (id)arrayWithCapacity:(int)numItems; -@end - -@interface NSBundle : NSObject {} -+ (NSBundle *)bundleForClass:(Class)aClass; -- (NSString *)bundlePath; -- (void)setBundlePath:(NSString *)x; -@end - -@interface NSException : NSObject {} -@end - -@class NSArray, NSDictionary, NSError, NSString, NSURL; - -@interface DTPlugInManager : NSObject -@end - -@implementation DTPlugInManager -+ (DTPlugInManager *)defaultPlugInManager { - @try { - NSMutableArray *plugInPaths = [NSMutableArray arrayWithCapacity:100]; - NSBundle *frameworkBundle = [NSBundle bundleForClass:[DTPlugInManager class]]; - frameworkBundle.bundlePath = 0; - [plugInPaths addObject:frameworkBundle.bundlePath]; - } - @catch (NSException *exception) {} -} -@end diff --git a/clang/test/SemaObjC/objc-property-7.m b/clang/test/SemaObjC/objc-property-7.m deleted file mode 100644 index ef7a98ad89c..00000000000 --- a/clang/test/SemaObjC/objc-property-7.m +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -typedef struct _NSZone NSZone; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@interface NSObject {} -@end - -@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray; - -@interface SCMObject : NSObject {} - @property(assign) SCMObject *__attribute__((objc_gc(weak))) parent; -@end - -@interface SCMNode : SCMObject -{ - NSString *_name; -} -@property(copy) NSString *name; -@end - -@implementation SCMNode - @synthesize name = _name; - - (void) setParent:(SCMNode*) inParent { - super.parent = inParent; - } -@end diff --git a/clang/test/SemaObjC/objc-property-8.m b/clang/test/SemaObjC/objc-property-8.m deleted file mode 100644 index 8ca0afc1ed4..00000000000 --- a/clang/test/SemaObjC/objc-property-8.m +++ /dev/null @@ -1,74 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; - -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject - (BOOL)isEqual:(id)object; @end -@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end -@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end -@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end - -@interface NSObject {} @end - -typedef float CGFloat; - -typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3 } NSFastEnumerationState; - -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end - -@class NSString; - -@interface NSDictionary : NSObject -- (NSUInteger)count; -@end - -extern NSString * const NSBundleDidLoadNotification; - -@interface NSObject(NSKeyValueObserving) -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; -- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath; -@end - -enum { NSCaseInsensitivePredicateOption = 0x01, NSDiacriticInsensitivePredicateOption = 0x02 }; - -@interface NSResponder : NSObject {} -@end - -extern NSString * const NSFullScreenModeAllScreens; -@interface NSWindowController : NSResponder {} -@end - -extern NSString *NSAlignmentBinding ; - -@interface _XCOQQuery : NSObject {} -@end - -extern NSString *PBXWindowDidChangeFirstResponderNotification; - -@interface PBXModule : NSWindowController {} -@end - -@class _XCOQHelpTextBackgroundView; -@interface PBXOpenQuicklyModule : PBXModule -{ -@private - _XCOQQuery *_query; -} -@end - -@interface PBXOpenQuicklyModule () -@property(readwrite, retain) _XCOQQuery *query; -@end - -@implementation PBXOpenQuicklyModule -@synthesize query = _query; -- (void) _clearQuery -{ - [self.query removeObserver: self forKeyPath: @"matches"]; -} -@end - diff --git a/clang/test/SemaObjC/objc-property-9-impl-method.m b/clang/test/SemaObjC/objc-property-9-impl-method.m deleted file mode 100644 index bb13d01b74a..00000000000 --- a/clang/test/SemaObjC/objc-property-9-impl-method.m +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: clang %s -fsyntax-only -verify -// rdar://5967199 - -typedef signed char BOOL; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL) isEqual:(id) object; -@end - -@protocol NSCoding -- (void) encodeWithCoder:(NSCoder *) aCoder; -@end - -@interface NSObject < NSObject > {} -@end - -typedef float CGFloat; -typedef struct _NSPoint {} NSSize; -typedef struct _NSRect {} NSRect; -typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3} NSRectEdge; -extern void NSDivideRect(NSRect inRect, NSRect * slice, NSRect * rem, CGFloat amount, NSRectEdge edge); - -@interface NSResponder:NSObject < NSCoding > {} -@end - -@protocol NSAnimatablePropertyContainer -- (id) animator; -@end - -extern NSString *NSAnimationTriggerOrderIn; - -@interface NSView:NSResponder < NSAnimatablePropertyContainer > {} --(NSRect) bounds; -@end - -enum { - NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered -}; - -@interface NSTabView:NSView {} -@end - -@ class OrganizerTabHeader; - -@interface OrganizerTabView:NSTabView {} -@property(assign) -NSSize minimumSize; -@end - -@interface OrganizerTabView() -@property(readonly) OrganizerTabHeader *tabHeaderView; -@property(readonly) NSRect headerRect; -@end - -@implementation OrganizerTabView -@dynamic tabHeaderView, headerRect, minimumSize; --(CGFloat) tabAreaThickness {} --(NSRectEdge) rectEdgeForTabs { - NSRect dummy, result = {}; - NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs); -} - diff --git a/clang/test/SemaObjC/objc-props-on-prots.m b/clang/test/SemaObjC/objc-props-on-prots.m deleted file mode 100644 index aa5be257954..00000000000 --- a/clang/test/SemaObjC/objc-props-on-prots.m +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL) isEqual:(id) object; -@end - -@protocol NSCoding -- (void) encodeWithCoder:(NSCoder *) aCoder; -@end - -@interface NSObject < NSObject > {} @end - -typedef float CGFloat; - -@interface NSResponder:NSObject < NSCoding > {} @end - -@class XCElementView; - -typedef struct _XCElementInset {} XCElementInset; - -@protocol XCElementP < NSObject > --(BOOL) vertical; -@end - -@protocol XCElementDisplayDelegateP; -@protocol XCElementTabMarkerP; - -typedef NSObject < XCElementTabMarkerP > XCElementTabMarker; - -@protocol XCElementTabberP < XCElementP > --(void) setMarker:(XCElementTabMarker *) marker; -@end - -typedef NSObject < XCElementTabberP > XCElementTabber; - -@protocol XCElementTabMarkerP < NSObject > -@property(nonatomic) -BOOL variableSized; -@end - -@protocol XCElementJustifierP < XCElementP > --(void) setHJustification:(CGFloat) hJust; -@end - -typedef NSObject < XCElementJustifierP > XCElementJustifier; -@interface XCElementImp:NSObject < XCElementP > {} -@end - -@class XCElementImp; - -@interface XCElementTabberImp:XCElementImp < XCElementTabberP > { - XCElementTabMarker *_marker; -} -@end - -@implementation XCElementTabberImp -- (void) setMarker:(XCElementTabMarker *) marker { - if (_marker && _marker.variableSized) { - } -} -- vertical { return self; } -- (BOOL)isEqual:x { return 1; } -@end diff --git a/clang/test/SemaObjC/objc-protocol-1.m b/clang/test/SemaObjC/objc-protocol-1.m deleted file mode 100644 index 3ace0ac3de0..00000000000 --- a/clang/test/SemaObjC/objc-protocol-1.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -// rdar://5986251 - -@protocol SomeProtocol -- (void) bar; -@end - -void foo(id x) { - bar((short)x); // expected-error {{expected ')'}} expected-error {{to match this '('}} - bar(()x); // expected-warning {{protocol qualifiers without 'id' is archaic}} - - [()x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}} -} - diff --git a/clang/test/SemaObjC/objc-string.m b/clang/test/SemaObjC/objc-string.m deleted file mode 100644 index e3974ad8f66..00000000000 --- a/clang/test/SemaObjC/objc-string.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: clang %s -verify -fsyntax-only && -// RUN: clang %s -verify -fsyntax-only -DDECLAREIT - -// a declaration of NSConstantString is not required. -#ifdef DECLAREIT -@interface NSConstantString; -@end -#endif - - - -id s = @"123"; // simple -id t = @"123" @"456"; // concat -id u = @"123" @ blah; // expected-error: {{unexpected token}} - diff --git a/clang/test/SemaObjC/objc-synchronized.m b/clang/test/SemaObjC/objc-synchronized.m deleted file mode 100644 index 365da92dd4b..00000000000 --- a/clang/test/SemaObjC/objc-synchronized.m +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end - -@protocol NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end - -@interface NSObject {} @end - -typedef float CGFloat; -typedef struct { int a; } NSFastEnumerationState; - -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end - -typedef unsigned short unichar; - -@interface NSString : NSObject -- (NSUInteger)length; -@end - -@interface NSSimpleCString : NSString {} @end - -@interface NSConstantString : NSSimpleCString @end - -extern void *_NSConstantStringClassReference; - -@interface NSDictionary : NSObject -- (NSUInteger)count; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)removeObjectForKey:(id)aKey; -@end - -@class NSArray, NSSet, NSHashTable; - -@protocol PBXTrackableTask -- (float) taskPercentComplete; -- taskIdentifier; -@end - -@interface PBXTrackableTaskManager : NSObject { - NSMutableDictionary *_trackableTasks; -} -@end - -NSString *XCExecutableDebugTaskIdentifier = @"XCExecutableDebugTaskIdentifier"; - -@implementation PBXTrackableTaskManager -- (id) init {} -- (void) unregisterTask:(id ) task { - @synchronized (self) { - id taskID = [task taskIdentifier]; - id task = [_trackableTasks objectForKey:taskID]; // expected-warning{{method '-objectForKey:' not found (return type defaults to 'id')}} - } -} -@end - diff --git a/clang/test/SemaObjC/objc-try-catch.m b/clang/test/SemaObjC/objc-try-catch.m deleted file mode 100644 index e4c20b73438..00000000000 --- a/clang/test/SemaObjC/objc-try-catch.m +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -typedef struct _NSZone NSZone; - -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end - -@interface NSObject {} -@end - -@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale; - -@interface NSException : NSObject {} -@end - -@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo; - -@interface XCRefactoringTransformation : NSObject {} -@end - -@implementation XCRefactoringTransformation -- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; { - @try {} - // the exception name is optional (weird) - @catch (NSException *) {} -} diff --git a/clang/test/SemaObjC/objc-typedef-class.m b/clang/test/SemaObjC/objc-typedef-class.m deleted file mode 100644 index 1bb3f87aa5a..00000000000 --- a/clang/test/SemaObjC/objc-typedef-class.m +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: clang -fsyntax-only -verify %s -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; - -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; - -@protocol NSObject - (BOOL) isEqual:(id) object; @end -@protocol NSCopying - (id) copyWithZone:(NSZone *) zone; @end -@protocol NSCoding - (void) encodeWithCoder:(NSCoder *) aCoder; @end - -@interface NSObject < NSObject > {} -+(id) alloc; -@end - -typedef float CGFloat; - -@interface NSTask:NSObject -- (id) init; -@end - -typedef NSUInteger NSControlSize; -typedef struct __CFlags {} _CFlags; - -@interface NSCell:NSObject < NSCopying, NSCoding > {} -@end - -@interface NSActionCell:NSCell {} @end - -@class NSAttributedString, NSFont, NSImage, NSSound; - -typedef struct _XCElementInset {} XCElementInset; - -@protocol XCElementP < NSObject > --(BOOL) vertical; -@end - -@protocol XCElementDisplayDelegateP; -@protocol XCElementDisplayDelegateP < NSObject > --(void) configureForControlSize:(NSControlSize)size font:(NSFont *)font addDefaultSpace:(XCElementInset) additionalSpace; -@end - -@protocol XCElementSpacerP < XCElementP > -@end - -typedef NSObject < XCElementSpacerP > XCElementSpacer; - -@protocol XCElementTogglerP < XCElementP > -(void) setDisplayed:(BOOL) displayed; -@end - -typedef NSObject < XCElementTogglerP > XCElementToggler; - -@interface XCElementRootFace:NSObject {} @end - -@interface XCElementFace:XCElementRootFace {} @end - -@class XCElementToggler; - -@interface XCRASlice:XCElementFace {} @end - -@class XCElementSpacings; - -@interface XCElementDisplay:NSObject < XCElementDisplayDelegateP > {} @end -@interface XCElementDisplayRect:XCElementDisplay {} @end - -typedef XCElementDisplayRect XCElementGraphicsRect; - -@interface XCElementDisplayFillerImage:XCElementDisplay {} @end - -@implementation XCRASlice -- (void) addSliceWithLabel:(NSString *)label statusKey:(NSString *)statusKey disclosed:(BOOL)disclosed -{ - static XCElementGraphicsRect *_sGraphicsDelegate = ((void *) 0); - if (!_sGraphicsDelegate) { - _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init]; - } -} -@end diff --git a/clang/test/SemaObjC/objc-types-compatible.m b/clang/test/SemaObjC/objc-types-compatible.m deleted file mode 100644 index bd8a7490c41..00000000000 --- a/clang/test/SemaObjC/objc-types-compatible.m +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: clang -fsyntax-only -verify -pedantic %s -typedef signed char BOOL; -typedef int NSInteger; - -@class NSString; - -@protocol PBXCompletionItem -- (NSString *) name; -- (NSInteger)priority; -@end - -extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context); - -NSInteger codeAssistantCaseCompareItems(id a, id b, void *context) -{ -} - -#if 0 -FIXME: clang needs to compare each method prototype with its definition (see below). - -GCC produces the following correct warnning: -[snaroff:llvm/tools/clang] snarofflocal% cc -c test/Sema/objc-types-compatible.m -test/Sema/objc-types-compatible.m: In function ‘-[TedWantsToVerifyObjCDoesTheRightThing compareThis:withThat:]’: -test/Sema/objc-types-compatible.m:26: warning: conflicting types for ‘-(id)compareThis:(id )a withThat:(id )b’ -test/Sema/objc-types-compatible.m:20: warning: previous declaration of ‘-(id)compareThis:(int)a withThat:(id)b’ -#endif - -@interface TedWantsToVerifyObjCDoesTheRightThing - -- compareThis:(int)a withThat:(id)b; - -@end - -@implementation TedWantsToVerifyObjCDoesTheRightThing - -- compareThis:(id)a withThat:(id)b { - return self; -} - -@end diff --git a/clang/test/SemaObjC/objc-unused.m b/clang/test/SemaObjC/objc-unused.m deleted file mode 100644 index cbe15a1abb5..00000000000 --- a/clang/test/SemaObjC/objc-unused.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: clang %s -verify -fsyntax-only -#include - -@interface Greeter -+ (void) hello; -@end - -@implementation Greeter -+ (void) hello { - fprintf(stdout, "Hello, World!\n"); -} -@end - -int main (void) { - [Greeter hello]; - return 0; -} - diff --git a/clang/test/SemaObjC/property-1.m b/clang/test/SemaObjC/property-1.m new file mode 100644 index 00000000000..3bc2e3386b0 --- /dev/null +++ b/clang/test/SemaObjC/property-1.m @@ -0,0 +1,39 @@ +// RUN: clang -fsyntax-only -verify %s + +@interface I +{ + int IVAR; + int name; +} +@property int d1; +@property id prop_id; +@property int name; +@end + +@interface I(CAT) +@property int d1; +@end + +@implementation I +@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}} +@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}} +@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} +@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' does not match type of ivar 'IVAR'}} +@synthesize name; // OK! property with same name as an accessible ivar of same name +@end + +@implementation I(CAT) +@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 + +@implementation E // expected-warning {{cannot find interface declaration for 'E'}} +@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}} +@end + +@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}} +@dynamic d; // expected-error {{property implementation in a category with no category declaration}} +@end + + + diff --git a/clang/test/SemaObjC/property-2.m b/clang/test/SemaObjC/property-2.m new file mode 100644 index 00000000000..4472a8f6955 --- /dev/null +++ b/clang/test/SemaObjC/property-2.m @@ -0,0 +1,63 @@ +// RUN: clang -fsyntax-only -verify %s + +@interface Tester +@property char PropertyAtomic_char; +@property short PropertyAtomic_short; +@property int PropertyAtomic_int; +@property long PropertyAtomic_long; +@property long long PropertyAtomic_longlong; +@property float PropertyAtomic_float; +@property double PropertyAtomic_double; +@property(assign) id PropertyAtomic_id; +@property(retain) id PropertyAtomicRetained_id; +@property(copy) id PropertyAtomicRetainedCopied_id; +@property(retain) id PropertyAtomicRetainedGCOnly_id; +@property(copy) id PropertyAtomicRetainedCopiedGCOnly_id; +@end + +@implementation Tester +@dynamic PropertyAtomic_char; +@dynamic PropertyAtomic_short; +@dynamic PropertyAtomic_int; +@dynamic PropertyAtomic_long; +@dynamic PropertyAtomic_longlong; +@dynamic PropertyAtomic_float; +@dynamic PropertyAtomic_double; +@dynamic PropertyAtomic_id; +@dynamic PropertyAtomicRetained_id; +@dynamic PropertyAtomicRetainedCopied_id; +@dynamic PropertyAtomicRetainedGCOnly_id; +@dynamic PropertyAtomicRetainedCopiedGCOnly_id; +@end + +@interface SubClass : Tester +{ + char PropertyAtomic_char; + short PropertyAtomic_short; + int PropertyAtomic_int; + long PropertyAtomic_long; + long long PropertyAtomic_longlong; + float PropertyAtomic_float; + double PropertyAtomic_double; + id PropertyAtomic_id; + id PropertyAtomicRetained_id; + id PropertyAtomicRetainedCopied_id; + id PropertyAtomicRetainedGCOnly_id; + id PropertyAtomicRetainedCopiedGCOnly_id; +} +@end + +@implementation SubClass +@synthesize PropertyAtomic_char; +@synthesize PropertyAtomic_short; +@synthesize PropertyAtomic_int; +@synthesize PropertyAtomic_long; +@synthesize PropertyAtomic_longlong; +@synthesize PropertyAtomic_float; +@synthesize PropertyAtomic_double; +@synthesize PropertyAtomic_id; +@synthesize PropertyAtomicRetained_id; +@synthesize PropertyAtomicRetainedCopied_id; +@synthesize PropertyAtomicRetainedGCOnly_id; +@synthesize PropertyAtomicRetainedCopiedGCOnly_id; +@end diff --git a/clang/test/SemaObjC/property-3.m b/clang/test/SemaObjC/property-3.m new file mode 100644 index 00000000000..b22059c2382 --- /dev/null +++ b/clang/test/SemaObjC/property-3.m @@ -0,0 +1,14 @@ +// RUN: clang -verify %s + +@interface I +{ + id d1; +} +@property (readwrite, copy) id d1; +@property (readwrite, copy) id d2; +@end + +@interface NOW : I +@property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from'I'}} +@property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}} +@end diff --git a/clang/test/SemaObjC/property-4.m b/clang/test/SemaObjC/property-4.m new file mode 100644 index 00000000000..b5a8f8b1ccb --- /dev/null +++ b/clang/test/SemaObjC/property-4.m @@ -0,0 +1,30 @@ +// RUN: clang -verify %s + +@interface Object +@end + +@protocol ProtocolObject +@property int class; +@property (copy) id MayCauseError; +@end + +@protocol ProtocolDerivedGCObject +@property int Dclass; +@end + +@interface GCObject : Object { + int ifield; + int iOwnClass; + int iDclass; +} +@property int OwnClass; +@end + +@interface ReleaseObject : GCObject { + int newO; + int oldO; +} +@property (retain) id MayCauseError; // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'GCObject'}} \ + expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from'ProtocolObject'}} +@end + diff --git a/clang/test/SemaObjC/property-5.m b/clang/test/SemaObjC/property-5.m new file mode 100644 index 00000000000..c467e634dcc --- /dev/null +++ b/clang/test/SemaObjC/property-5.m @@ -0,0 +1,31 @@ +// RUN: clang -verify %s + +@protocol P1 @end +@protocol P2 @end +@protocol P3 @end + +@interface NSData @end + +@interface MutableNSData : NSData @end + +@interface Base : NSData +@property(readonly) id ref; +@property(readonly) Base *p_base; +@property(readonly) NSData *nsdata; +@property(readonly) NSData * m_nsdata; +@end + +@interface Data : Base +@property(readonly) NSData *ref; // expected-warning {{property type 'NSData *' does not match property type inherited from 'Base'}} +@property(readonly) Data *p_base; // expected-warning {{property type 'Data *' does not match property type inherited from 'Base'}} +@property(readonly) MutableNSData * m_nsdata; // expected-warning {{property type 'MutableNSData *' does not match property type inherited from 'Base'}} +@end + +@interface MutedData: Data +@property(readonly) id p_base; // expected-warning {{property type 'id' does not match property type inherited from 'Data'}} +@end + +@interface ConstData : Data +@property(readonly) ConstData *p_base; // expected-warning {{property type 'ConstData *' does not match property type inherited from 'Data'}} +@end + diff --git a/clang/test/SemaObjC/property-6.m b/clang/test/SemaObjC/property-6.m new file mode 100644 index 00000000000..a51994d3d49 --- /dev/null +++ b/clang/test/SemaObjC/property-6.m @@ -0,0 +1,69 @@ +// RUN: clang -fsyntax-only -verify %s +# 1 "" +# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3 +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL)isEqual:(id)object; ++ class; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@protocol NSMutableCopying +- (id)mutableCopyWithZone:(NSZone *)zone; +@end + +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end + +@interface NSObject {} +@end + +typedef struct {} NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end + +@interface NSArray : NSObject +- (NSUInteger)count; +@end + +@interface NSMutableArray : NSArray +- (void)addObject:(id)anObject; ++ (id)arrayWithCapacity:(int)numItems; +@end + +@interface NSBundle : NSObject {} ++ (NSBundle *)bundleForClass:(Class)aClass; +- (NSString *)bundlePath; +- (void)setBundlePath:(NSString *)x; +@end + +@interface NSException : NSObject {} +@end + +@class NSArray, NSDictionary, NSError, NSString, NSURL; + +@interface DTPlugInManager : NSObject +@end + +@implementation DTPlugInManager ++ (DTPlugInManager *)defaultPlugInManager { + @try { + NSMutableArray *plugInPaths = [NSMutableArray arrayWithCapacity:100]; + NSBundle *frameworkBundle = [NSBundle bundleForClass:[DTPlugInManager class]]; + frameworkBundle.bundlePath = 0; + [plugInPaths addObject:frameworkBundle.bundlePath]; + } + @catch (NSException *exception) {} +} +@end diff --git a/clang/test/SemaObjC/property-7.m b/clang/test/SemaObjC/property-7.m new file mode 100644 index 00000000000..ef7a98ad89c --- /dev/null +++ b/clang/test/SemaObjC/property-7.m @@ -0,0 +1,34 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef struct _NSZone NSZone; + +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@interface NSObject {} +@end + +@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray; + +@interface SCMObject : NSObject {} + @property(assign) SCMObject *__attribute__((objc_gc(weak))) parent; +@end + +@interface SCMNode : SCMObject +{ + NSString *_name; +} +@property(copy) NSString *name; +@end + +@implementation SCMNode + @synthesize name = _name; + - (void) setParent:(SCMNode*) inParent { + super.parent = inParent; + } +@end diff --git a/clang/test/SemaObjC/property-8.m b/clang/test/SemaObjC/property-8.m new file mode 100644 index 00000000000..8ca0afc1ed4 --- /dev/null +++ b/clang/test/SemaObjC/property-8.m @@ -0,0 +1,74 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end +@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end + +@interface NSObject {} @end + +typedef float CGFloat; + +typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3 } NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end + +@class NSString; + +@interface NSDictionary : NSObject +- (NSUInteger)count; +@end + +extern NSString * const NSBundleDidLoadNotification; + +@interface NSObject(NSKeyValueObserving) +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; +- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath; +@end + +enum { NSCaseInsensitivePredicateOption = 0x01, NSDiacriticInsensitivePredicateOption = 0x02 }; + +@interface NSResponder : NSObject {} +@end + +extern NSString * const NSFullScreenModeAllScreens; +@interface NSWindowController : NSResponder {} +@end + +extern NSString *NSAlignmentBinding ; + +@interface _XCOQQuery : NSObject {} +@end + +extern NSString *PBXWindowDidChangeFirstResponderNotification; + +@interface PBXModule : NSWindowController {} +@end + +@class _XCOQHelpTextBackgroundView; +@interface PBXOpenQuicklyModule : PBXModule +{ +@private + _XCOQQuery *_query; +} +@end + +@interface PBXOpenQuicklyModule () +@property(readwrite, retain) _XCOQQuery *query; +@end + +@implementation PBXOpenQuicklyModule +@synthesize query = _query; +- (void) _clearQuery +{ + [self.query removeObserver: self forKeyPath: @"matches"]; +} +@end + diff --git a/clang/test/SemaObjC/property-9-impl-method.m b/clang/test/SemaObjC/property-9-impl-method.m new file mode 100644 index 00000000000..bb13d01b74a --- /dev/null +++ b/clang/test/SemaObjC/property-9-impl-method.m @@ -0,0 +1,63 @@ +// RUN: clang %s -fsyntax-only -verify +// rdar://5967199 + +typedef signed char BOOL; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL) isEqual:(id) object; +@end + +@protocol NSCoding +- (void) encodeWithCoder:(NSCoder *) aCoder; +@end + +@interface NSObject < NSObject > {} +@end + +typedef float CGFloat; +typedef struct _NSPoint {} NSSize; +typedef struct _NSRect {} NSRect; +typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3} NSRectEdge; +extern void NSDivideRect(NSRect inRect, NSRect * slice, NSRect * rem, CGFloat amount, NSRectEdge edge); + +@interface NSResponder:NSObject < NSCoding > {} +@end + +@protocol NSAnimatablePropertyContainer +- (id) animator; +@end + +extern NSString *NSAnimationTriggerOrderIn; + +@interface NSView:NSResponder < NSAnimatablePropertyContainer > {} +-(NSRect) bounds; +@end + +enum { + NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered +}; + +@interface NSTabView:NSView {} +@end + +@ class OrganizerTabHeader; + +@interface OrganizerTabView:NSTabView {} +@property(assign) +NSSize minimumSize; +@end + +@interface OrganizerTabView() +@property(readonly) OrganizerTabHeader *tabHeaderView; +@property(readonly) NSRect headerRect; +@end + +@implementation OrganizerTabView +@dynamic tabHeaderView, headerRect, minimumSize; +-(CGFloat) tabAreaThickness {} +-(NSRectEdge) rectEdgeForTabs { + NSRect dummy, result = {}; + NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs); +} + diff --git a/clang/test/SemaObjC/props-on-prots.m b/clang/test/SemaObjC/props-on-prots.m new file mode 100644 index 00000000000..aa5be257954 --- /dev/null +++ b/clang/test/SemaObjC/props-on-prots.m @@ -0,0 +1,65 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL) isEqual:(id) object; +@end + +@protocol NSCoding +- (void) encodeWithCoder:(NSCoder *) aCoder; +@end + +@interface NSObject < NSObject > {} @end + +typedef float CGFloat; + +@interface NSResponder:NSObject < NSCoding > {} @end + +@class XCElementView; + +typedef struct _XCElementInset {} XCElementInset; + +@protocol XCElementP < NSObject > +-(BOOL) vertical; +@end + +@protocol XCElementDisplayDelegateP; +@protocol XCElementTabMarkerP; + +typedef NSObject < XCElementTabMarkerP > XCElementTabMarker; + +@protocol XCElementTabberP < XCElementP > +-(void) setMarker:(XCElementTabMarker *) marker; +@end + +typedef NSObject < XCElementTabberP > XCElementTabber; + +@protocol XCElementTabMarkerP < NSObject > +@property(nonatomic) +BOOL variableSized; +@end + +@protocol XCElementJustifierP < XCElementP > +-(void) setHJustification:(CGFloat) hJust; +@end + +typedef NSObject < XCElementJustifierP > XCElementJustifier; +@interface XCElementImp:NSObject < XCElementP > {} +@end + +@class XCElementImp; + +@interface XCElementTabberImp:XCElementImp < XCElementTabberP > { + XCElementTabMarker *_marker; +} +@end + +@implementation XCElementTabberImp +- (void) setMarker:(XCElementTabMarker *) marker { + if (_marker && _marker.variableSized) { + } +} +- vertical { return self; } +- (BOOL)isEqual:x { return 1; } +@end diff --git a/clang/test/SemaObjC/protocol-archane.m b/clang/test/SemaObjC/protocol-archane.m new file mode 100644 index 00000000000..3ace0ac3de0 --- /dev/null +++ b/clang/test/SemaObjC/protocol-archane.m @@ -0,0 +1,14 @@ +// RUN: clang -fsyntax-only -verify %s +// rdar://5986251 + +@protocol SomeProtocol +- (void) bar; +@end + +void foo(id x) { + bar((short)x); // expected-error {{expected ')'}} expected-error {{to match this '('}} + bar(()x); // expected-warning {{protocol qualifiers without 'id' is archaic}} + + [()x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}} +} + diff --git a/clang/test/SemaObjC/string.m b/clang/test/SemaObjC/string.m new file mode 100644 index 00000000000..e3974ad8f66 --- /dev/null +++ b/clang/test/SemaObjC/string.m @@ -0,0 +1,15 @@ +// RUN: clang %s -verify -fsyntax-only && +// RUN: clang %s -verify -fsyntax-only -DDECLAREIT + +// a declaration of NSConstantString is not required. +#ifdef DECLAREIT +@interface NSConstantString; +@end +#endif + + + +id s = @"123"; // simple +id t = @"123" @"456"; // concat +id u = @"123" @ blah; // expected-error: {{unexpected token}} + diff --git a/clang/test/SemaObjC/synchronized.m b/clang/test/SemaObjC/synchronized.m new file mode 100644 index 00000000000..365da92dd4b --- /dev/null +++ b/clang/test/SemaObjC/synchronized.m @@ -0,0 +1,75 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@protocol NSMutableCopying +- (id)mutableCopyWithZone:(NSZone *)zone; +@end + +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end + +@interface NSObject {} @end + +typedef float CGFloat; +typedef struct { int a; } NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end + +typedef unsigned short unichar; + +@interface NSString : NSObject +- (NSUInteger)length; +@end + +@interface NSSimpleCString : NSString {} @end + +@interface NSConstantString : NSSimpleCString @end + +extern void *_NSConstantStringClassReference; + +@interface NSDictionary : NSObject +- (NSUInteger)count; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)removeObjectForKey:(id)aKey; +@end + +@class NSArray, NSSet, NSHashTable; + +@protocol PBXTrackableTask +- (float) taskPercentComplete; +- taskIdentifier; +@end + +@interface PBXTrackableTaskManager : NSObject { + NSMutableDictionary *_trackableTasks; +} +@end + +NSString *XCExecutableDebugTaskIdentifier = @"XCExecutableDebugTaskIdentifier"; + +@implementation PBXTrackableTaskManager +- (id) init {} +- (void) unregisterTask:(id ) task { + @synchronized (self) { + id taskID = [task taskIdentifier]; + id task = [_trackableTasks objectForKey:taskID]; // expected-warning{{method '-objectForKey:' not found (return type defaults to 'id')}} + } +} +@end + diff --git a/clang/test/SemaObjC/try-catch.m b/clang/test/SemaObjC/try-catch.m new file mode 100644 index 00000000000..e4c20b73438 --- /dev/null +++ b/clang/test/SemaObjC/try-catch.m @@ -0,0 +1,37 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef struct _NSZone NSZone; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end + +@protocol NSCopying +- (id)copyWithZone:(NSZone *)zone; +@end + +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end + +@interface NSObject {} +@end + +@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale; + +@interface NSException : NSObject {} +@end + +@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo; + +@interface XCRefactoringTransformation : NSObject {} +@end + +@implementation XCRefactoringTransformation +- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; { + @try {} + // the exception name is optional (weird) + @catch (NSException *) {} +} diff --git a/clang/test/SemaObjC/typedef-class.m b/clang/test/SemaObjC/typedef-class.m new file mode 100644 index 00000000000..1bb3f87aa5a --- /dev/null +++ b/clang/test/SemaObjC/typedef-class.m @@ -0,0 +1,78 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; + +@protocol NSObject - (BOOL) isEqual:(id) object; @end +@protocol NSCopying - (id) copyWithZone:(NSZone *) zone; @end +@protocol NSCoding - (void) encodeWithCoder:(NSCoder *) aCoder; @end + +@interface NSObject < NSObject > {} ++(id) alloc; +@end + +typedef float CGFloat; + +@interface NSTask:NSObject +- (id) init; +@end + +typedef NSUInteger NSControlSize; +typedef struct __CFlags {} _CFlags; + +@interface NSCell:NSObject < NSCopying, NSCoding > {} +@end + +@interface NSActionCell:NSCell {} @end + +@class NSAttributedString, NSFont, NSImage, NSSound; + +typedef struct _XCElementInset {} XCElementInset; + +@protocol XCElementP < NSObject > +-(BOOL) vertical; +@end + +@protocol XCElementDisplayDelegateP; +@protocol XCElementDisplayDelegateP < NSObject > +-(void) configureForControlSize:(NSControlSize)size font:(NSFont *)font addDefaultSpace:(XCElementInset) additionalSpace; +@end + +@protocol XCElementSpacerP < XCElementP > +@end + +typedef NSObject < XCElementSpacerP > XCElementSpacer; + +@protocol XCElementTogglerP < XCElementP > -(void) setDisplayed:(BOOL) displayed; +@end + +typedef NSObject < XCElementTogglerP > XCElementToggler; + +@interface XCElementRootFace:NSObject {} @end + +@interface XCElementFace:XCElementRootFace {} @end + +@class XCElementToggler; + +@interface XCRASlice:XCElementFace {} @end + +@class XCElementSpacings; + +@interface XCElementDisplay:NSObject < XCElementDisplayDelegateP > {} @end +@interface XCElementDisplayRect:XCElementDisplay {} @end + +typedef XCElementDisplayRect XCElementGraphicsRect; + +@interface XCElementDisplayFillerImage:XCElementDisplay {} @end + +@implementation XCRASlice +- (void) addSliceWithLabel:(NSString *)label statusKey:(NSString *)statusKey disclosed:(BOOL)disclosed +{ + static XCElementGraphicsRect *_sGraphicsDelegate = ((void *) 0); + if (!_sGraphicsDelegate) { + _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init]; + } +} +@end diff --git a/clang/test/SemaObjC/unused.m b/clang/test/SemaObjC/unused.m new file mode 100644 index 00000000000..cbe15a1abb5 --- /dev/null +++ b/clang/test/SemaObjC/unused.m @@ -0,0 +1,18 @@ +// RUN: clang %s -verify -fsyntax-only +#include + +@interface Greeter ++ (void) hello; +@end + +@implementation Greeter ++ (void) hello { + fprintf(stdout, "Hello, World!\n"); +} +@end + +int main (void) { + [Greeter hello]; + return 0; +} + -- cgit v1.2.3