aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjCXX
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2010-09-17 15:54:40 +0000
commit3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f (patch)
tree0bbe07708f7571f8b5291f6d7b96c102b7c99dee /test/SemaObjCXX
parenta0482fa4e7fa27b01184f938097f0666b78016dd (diff)
downloadsrc-3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f.tar.gz
src-3d1dcd9bfdb15c49ee34d576a065079ac5c4d29f.zip
Notes
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r--test/SemaObjCXX/conversion-to-objc-pointer-2.mm3
-rw-r--r--test/SemaObjCXX/cxxoperator-selector.mm24
-rw-r--r--test/SemaObjCXX/deduction.mm7
-rw-r--r--test/SemaObjCXX/exceptions-fragile.mm12
-rw-r--r--test/SemaObjCXX/expr-objcxx.mm4
-rw-r--r--test/SemaObjCXX/foreach-block.mm14
-rw-r--r--test/SemaObjCXX/instantiate-stmt.mm1
-rw-r--r--test/SemaObjCXX/message.mm2
-rw-r--r--test/SemaObjCXX/objc-decls-inside-namespace.mm5
-rw-r--r--test/SemaObjCXX/pointer-to-objc-pointer-conv.mm28
-rw-r--r--test/SemaObjCXX/references.mm36
-rw-r--r--test/SemaObjCXX/warn-strict-selector-match.mm18
12 files changed, 152 insertions, 2 deletions
diff --git a/test/SemaObjCXX/conversion-to-objc-pointer-2.mm b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
index 5277d101f588..b03d4d89e920 100644
--- a/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
+++ b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
@@ -82,6 +82,7 @@ int main (int argc, const char * argv[]) {
TNSAutoRef<NSObject*> object2([[NSObject alloc] init]);
TNSAutoRef<TBar*> bar([[TBar alloc] init]);
[bar setBlah: object1]; // <== Does not compile. It should.
- [bar setBlah: object2]; // <== Does not compile. It should.
+ if (object1 == object2)
+ [bar setBlah: object2]; // <== Does not compile. It should.
return 0;
}
diff --git a/test/SemaObjCXX/cxxoperator-selector.mm b/test/SemaObjCXX/cxxoperator-selector.mm
new file mode 100644
index 000000000000..6dd36a8c100e
--- /dev/null
+++ b/test/SemaObjCXX/cxxoperator-selector.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar:// 8328250
+
+@class NSDate;
+
+@interface XSGraphDataSet
+- and;
+- xor;
+- or;
+
+- ||; // expected-error {{expected selector for Objective-C method}}
+
+- &&; // expected-error {{expected selector for Objective-C method}}
+
+- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate;
+@end
+
+@implementation XSGraphDataSet
+- (id) and{return 0; };
+- (id) xor{return 0; };
+- (id) or{return 0; };
+
+- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate { return; }
+@end
diff --git a/test/SemaObjCXX/deduction.mm b/test/SemaObjCXX/deduction.mm
index 6dd449d6ea75..220f36863bab 100644
--- a/test/SemaObjCXX/deduction.mm
+++ b/test/SemaObjCXX/deduction.mm
@@ -56,3 +56,10 @@ namespace test1 {
template struct tester<Test1Class>; // expected-note {{in instantiation}}
template struct tester<Test1Class<Test1Protocol> >; // expected-note {{in instantiation}}
}
+
+namespace test2 {
+ template <typename T> void foo(const T* t) {}
+ void test(id x) {
+ foo(x);
+ }
+}
diff --git a/test/SemaObjCXX/exceptions-fragile.mm b/test/SemaObjCXX/exceptions-fragile.mm
new file mode 100644
index 000000000000..11dd8e94c1de
--- /dev/null
+++ b/test/SemaObjCXX/exceptions-fragile.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSException @end
+void opaque();
+
+namespace test0 {
+ void test() {
+ try {
+ } catch (NSException *e) { // expected-error {{can't catch Objective C exceptions in C++ in the non-unified exception model}}
+ }
+ }
+}
diff --git a/test/SemaObjCXX/expr-objcxx.mm b/test/SemaObjCXX/expr-objcxx.mm
new file mode 100644
index 000000000000..e70a001b7041
--- /dev/null
+++ b/test/SemaObjCXX/expr-objcxx.mm
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+// rdar://8366474
+void *P = @selector(foo::bar::);
diff --git a/test/SemaObjCXX/foreach-block.mm b/test/SemaObjCXX/foreach-block.mm
new file mode 100644
index 000000000000..91bd0c83b31b
--- /dev/null
+++ b/test/SemaObjCXX/foreach-block.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+// rdar://8295106
+
+int main() {
+id array;
+
+ for (int (^b)(void) in array) {
+ if (b() == 10000) {
+ return 1;
+ }
+ }
+
+ int (^b)(void) in array; // expected-error {{expected ';' at end of declaration}}
+}
diff --git a/test/SemaObjCXX/instantiate-stmt.mm b/test/SemaObjCXX/instantiate-stmt.mm
index e92f8e8d4f0c..5e8ec61573d4 100644
--- a/test/SemaObjCXX/instantiate-stmt.mm
+++ b/test/SemaObjCXX/instantiate-stmt.mm
@@ -25,6 +25,7 @@ template void synchronized_test(int); // expected-note{{in instantiation of}}
// fast enumeration
@interface NSArray
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount;
@end
@interface NSString
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 76bde6f57cab..f92518ad48c1 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -38,7 +38,7 @@ I2 *operator+(I2_holder, int);
return 0;
}
+ (void)method {
- [ivar method]; // expected-error{{receiver type 'ivar' (aka 'ivar') is not an Objective-C class}}
+ [ivar method]; // expected-error{{receiver type 'ivar' is not an Objective-C class}}
}
@end
diff --git a/test/SemaObjCXX/objc-decls-inside-namespace.mm b/test/SemaObjCXX/objc-decls-inside-namespace.mm
index 9953ec366e16..f68078b6779d 100644
--- a/test/SemaObjCXX/objc-decls-inside-namespace.mm
+++ b/test/SemaObjCXX/objc-decls-inside-namespace.mm
@@ -23,5 +23,10 @@ namespace C {
@implementation A(C) //expected-error{{Objective-C declarations may only appear in global scope}}
@end
+@interface B @end //expected-error{{Objective-C declarations may only appear in global scope}}
+@implementation B //expected-error{{Objective-C declarations may only appear in global scope}}
++ (void) foo {}
+@end
+
}
diff --git a/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm b/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
index 80383ebfd8a9..d0f8404b6027 100644
--- a/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
+++ b/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
@@ -19,3 +19,31 @@ void a() {
}
+
+// pr7936
+@interface I1 @end
+
+class Wrapper {
+public:
+ operator id() const { return (id)_value; }
+ operator Class() const { return (Class)_value; }
+ operator I1*() const { return (I1*)_value; }
+
+ bool Compare(id obj) { return *this == obj; }
+ bool CompareClass(Class obj) { return *this == obj; }
+ bool CompareI1(I1* obj) { return *this == obj; }
+
+ Wrapper &operator*();
+ Wrapper &operator[](int);
+ Wrapper& operator->*(int);
+
+private:
+ long _value;
+};
+
+void f() {
+ Wrapper w;
+ w[0];
+ *w;
+ w->*(0);
+}
diff --git a/test/SemaObjCXX/references.mm b/test/SemaObjCXX/references.mm
index 70ce8278e8f0..15033f6bde8d 100644
--- a/test/SemaObjCXX/references.mm
+++ b/test/SemaObjCXX/references.mm
@@ -24,3 +24,39 @@ int f2(A *a) {
return f0(a.p1); // expected-error {{property 'p1' not found on object of type 'A *'}}
}
+// PR7740
+@class NSString;
+
+void f3(id);
+void f4(NSString &tmpstr) {
+ f3(&tmpstr);
+}
+
+// PR7741
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+@interface foo<P1> {} @end
+@interface bar : foo <P1, P2> {} @end
+typedef bar baz;
+
+struct ToBar {
+ operator bar&() const;
+};
+
+void f5(foo&);
+void f5b(foo<P1>&);
+void f5c(foo<P2>&);
+void f5d(foo<P3>&);
+void f6(baz* x) {
+ f5(*x);
+ f5b(*x);
+ f5c(*x);
+ f5d(*x);
+ (void)((foo&)*x);
+ f5(ToBar());
+ f5b(ToBar());
+ f5c(ToBar());
+ f5d(ToBar());
+ (void)((foo&)ToBar());
+}
diff --git a/test/SemaObjCXX/warn-strict-selector-match.mm b/test/SemaObjCXX/warn-strict-selector-match.mm
new file mode 100644
index 000000000000..6d315db27cba
--- /dev/null
+++ b/test/SemaObjCXX/warn-strict-selector-match.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s
+
+@interface Base
+- (id) meth1: (Base *)arg1; // expected-note {{using}}
+- (id) window; // expected-note {{using}}
+@end
+
+@interface Derived: Base
+- (id) meth1: (Derived *)arg1; // expected-note {{also found}}
+- (Base *) window; // expected-note {{also found}}
+@end
+
+void foo(void) {
+ id r;
+
+ [r meth1:r]; // expected-warning {{multiple methods named 'meth1:' found [-Wstrict-selector-match]}}
+ [r window]; // expected-warning {{multiple methods named 'window' found [-Wstrict-selector-match]}}
+}