summaryrefslogtreecommitdiffstats
path: root/test/SemaObjCXX
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-05-27 15:17:06 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-05-27 15:17:06 +0000
commit53992adde3eda3ccf9da63bc7e45673f043de18f (patch)
tree3558f327a6f9ab59c5d7a06528d84e1560445247 /test/SemaObjCXX
parent7e411337c0ed226dace6e07f1420486768161308 (diff)
downloadFreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.zip
FreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.tar.gz
Update clang to r104832.
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r--test/SemaObjCXX/const-cast.mm13
-rw-r--r--test/SemaObjCXX/conversion-to-objc-pointer-2.mm87
-rw-r--r--test/SemaObjCXX/conversion-to-objc-pointer.mm50
-rw-r--r--test/SemaObjCXX/deduction.mm58
-rw-r--r--test/SemaObjCXX/ivar-construct.mm29
-rw-r--r--test/SemaObjCXX/ivar-struct.mm7
-rw-r--r--test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm51
-rw-r--r--test/SemaObjCXX/static-cast.mm29
-rw-r--r--test/SemaObjCXX/vla.mm2
-rw-r--r--test/SemaObjCXX/void_to_obj.mm15
10 files changed, 340 insertions, 1 deletions
diff --git a/test/SemaObjCXX/const-cast.mm b/test/SemaObjCXX/const-cast.mm
new file mode 100644
index 0000000..933fd47
--- /dev/null
+++ b/test/SemaObjCXX/const-cast.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class Foo;
+
+void test() {
+ const Foo *foo1 = 0;
+ Foo *foo2 = foo1; // expected-error {{cannot initialize}}
+}
+
+void test1() {
+ const Foo *foo1 = 0;
+ Foo *foo2 = const_cast<Foo*>(foo1);
+}
diff --git a/test/SemaObjCXX/conversion-to-objc-pointer-2.mm b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
new file mode 100644
index 0000000..5277d10
--- /dev/null
+++ b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+@protocol NSObject @end
+@interface NSObject
+- (id)init;
+- (id) alloc;
+- (id) autorelease;
+@end
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+
+#pragma mark -
+
+
+@protocol TFooProtocol <NSObject>
+
+- (void) foo;
+@end
+
+
+#pragma mark -
+
+
+@interface TFoo : NSObject
+
+- (void) setBlah: (id<TFooProtocol>)blah;
+@end
+
+
+#pragma mark -
+
+
+@implementation TFoo
+
+- (void) setBlah: (id<TFooProtocol>)blah
+ { }
+@end
+
+
+#pragma mark -
+
+
+@interface TBar : NSObject
+
+- (void) setBlah: (id)blah;
+@end
+
+#pragma mark -
+
+
+@implementation TBar
+
+- (void) setBlah: (id)blah
+ { }
+@end
+
+
+#pragma mark -
+
+
+int main (int argc, const char * argv[]) {
+
+ NSObject* object1 = [[[NSObject alloc] init] autorelease];
+ 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.
+ return 0;
+}
diff --git a/test/SemaObjCXX/conversion-to-objc-pointer.mm b/test/SemaObjCXX/conversion-to-objc-pointer.mm
new file mode 100644
index 0000000..235aaac
--- /dev/null
+++ b/test/SemaObjCXX/conversion-to-objc-pointer.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+ T Get() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+@interface NSObject
+- (id) alloc;
+- (id)init;
+@end
+
+@interface TFoo : NSObject
+- (void) foo;
+@end
+
+@implementation TFoo
+- (void) foo {}
+@end
+
+@interface TBar : NSObject
+- (void) foo;
+@end
+
+@implementation TBar
+- (void) foo {}
+@end
+
+int main () {
+ TNSAutoRef<TBar*> bar([[TBar alloc] init]);
+ [bar foo];
+ return 0;
+}
diff --git a/test/SemaObjCXX/deduction.mm b/test/SemaObjCXX/deduction.mm
new file mode 100644
index 0000000..6dd449d
--- /dev/null
+++ b/test/SemaObjCXX/deduction.mm
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class NSString;
+
+// Reduced from WebKit.
+namespace test0 {
+ template <typename T> struct RemovePointer {
+ typedef T Type;
+ };
+
+ template <typename T> struct RemovePointer<T*> {
+ typedef T Type;
+ };
+
+ template <typename T> struct RetainPtr {
+ typedef typename RemovePointer<T>::Type ValueType;
+ typedef ValueType* PtrType;
+ RetainPtr(PtrType ptr);
+ };
+
+ void test(NSString *S) {
+ RetainPtr<NSString*> ptr(S);
+ }
+
+ void test(id S) {
+ RetainPtr<id> ptr(S);
+ }
+}
+
+@class Test1Class;
+@protocol Test1Protocol;
+namespace test1 {
+ template <typename T> struct RemovePointer {
+ typedef T type;
+ };
+ template <typename T> struct RemovePointer<T*> {
+ typedef T type;
+ };
+ template <typename A, typename B> struct is_same {};
+ template <typename A> struct is_same<A,A> {
+ static void foo();
+ };
+ template <typename T> struct tester {
+ void test() {
+ is_same<T, typename RemovePointer<T>::type*>::foo(); // expected-error 2 {{no member named 'foo'}}
+ }
+ };
+
+ template struct tester<id>;
+ template struct tester<id<Test1Protocol> >;
+ template struct tester<Class>;
+ template struct tester<Class<Test1Protocol> >;
+ template struct tester<Test1Class*>;
+ template struct tester<Test1Class<Test1Protocol>*>;
+
+ template struct tester<Test1Class>; // expected-note {{in instantiation}}
+ template struct tester<Test1Class<Test1Protocol> >; // expected-note {{in instantiation}}
+}
diff --git a/test/SemaObjCXX/ivar-construct.mm b/test/SemaObjCXX/ivar-construct.mm
new file mode 100644
index 0000000..da066e9
--- /dev/null
+++ b/test/SemaObjCXX/ivar-construct.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct Y {
+ Y();
+
+private:
+ ~Y(); // expected-note 3{{declared private here}}
+};
+
+template<typename T>
+struct X : T { }; // expected-error 2{{private destructor}}
+
+struct Z; // expected-note{{forward declaration}}
+
+@interface A {
+ X<Y> x; // expected-note{{implicit default destructor}}
+ Y y; // expected-error{{private destructor}}
+}
+@end
+
+@implementation A // expected-note{{implicit default constructor}}
+@end
+
+@interface B {
+ Z z; // expected-error{{incomplete type}}
+}
+@end
+
+@implementation B
+@end
diff --git a/test/SemaObjCXX/ivar-struct.mm b/test/SemaObjCXX/ivar-struct.mm
new file mode 100644
index 0000000..3f9c7eb
--- /dev/null
+++ b/test/SemaObjCXX/ivar-struct.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface A {
+ struct X {
+ int x, y;
+ } X;
+}
+@end
diff --git a/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm b/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
new file mode 100644
index 0000000..7be5f17
--- /dev/null
+++ b/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
+@interface INTF @end
+
+extern INTF* p2;
+extern __strong INTF* p2;
+
+extern __strong id p1;
+extern id p1;
+
+extern id CFRunLoopGetMain();
+extern __strong id CFRunLoopGetMain();
+
+extern __strong id CFRunLoopGetMain2();
+extern id CFRunLoopGetMain2();
+
+extern INTF* CFRunLoopGetMain3();
+extern __strong INTF* CFRunLoopGetMain3();
+
+extern __strong INTF* CFRunLoopGetMain4();
+extern INTF* CFRunLoopGetMain4();
+
+typedef id ID;
+extern ID CFRunLoopGetMain5();
+extern __strong id CFRunLoopGetMain5();
+
+extern __strong id CFRunLoopGetMain6();
+extern ID CFRunLoopGetMain6();
+
+extern ID CFRunLoopGetMain7();
+extern __strong ID CFRunLoopGetMain7();
+
+extern __strong ID CFRunLoopGetMain8();
+extern ID CFRunLoopGetMain8();
+
+extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
+extern id WLoopGetMain(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+
+extern id p3; // expected-note {{previous definition is here}}
+extern __weak id p3; // expected-error {{redefinition of 'p3' with a different type}}
+
+extern void *p4; // expected-note {{previous definition is here}}
+extern void * __strong p4; // expected-error {{redefinition of 'p4' with a different type}}
+
+extern id p5;
+extern __strong id p5;
+
+extern char* __strong p6; // expected-note {{previous definition is here}}
+extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
+
+extern __strong char* p7; // expected-note {{previous definition is here}}
+extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
diff --git a/test/SemaObjCXX/static-cast.mm b/test/SemaObjCXX/static-cast.mm
new file mode 100644
index 0000000..e282702
--- /dev/null
+++ b/test/SemaObjCXX/static-cast.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol NSTextViewDelegate;
+
+@interface NSResponder @end
+
+class AutoreleaseObject
+{
+public:
+ AutoreleaseObject();
+ ~AutoreleaseObject();
+
+
+ AutoreleaseObject& operator=(NSResponder* inValue);
+ AutoreleaseObject& operator=(const AutoreleaseObject& inValue);
+
+ AutoreleaseObject(const AutoreleaseObject& inValue);
+
+ operator NSResponder*() const;
+};
+
+
+void InvokeSaveFocus()
+{
+ AutoreleaseObject mResolvedFirstResponder;
+ id<NSTextViewDelegate> Mydelegate;
+ mResolvedFirstResponder = static_cast<NSResponder*>(Mydelegate);
+}
+
diff --git a/test/SemaObjCXX/vla.mm b/test/SemaObjCXX/vla.mm
index 9c6fc54..d6da1c0 100644
--- a/test/SemaObjCXX/vla.mm
+++ b/test/SemaObjCXX/vla.mm
@@ -6,7 +6,7 @@
@end
void test(Data *d) {
- char buffer[[d length]]; // expected-error{{variable length arrays are not permitted in C++}}
+ char buffer[[d length]];
[d getData:buffer];
}
diff --git a/test/SemaObjCXX/void_to_obj.mm b/test/SemaObjCXX/void_to_obj.mm
index 52510c8..7dca9fa 100644
--- a/test/SemaObjCXX/void_to_obj.mm
+++ b/test/SemaObjCXX/void_to_obj.mm
@@ -9,3 +9,18 @@ void func() {
obj = vv; // expected-error{{assigning to 'XX *' from incompatible type 'void *'}}
}
+
+// <rdar://problem/7952457>
+@interface I
+{
+ void* delegate;
+}
+- (I*) Meth;
+- (I*) Meth1;
+@end
+
+@implementation I
+- (I*) Meth { return static_cast<I*>(delegate); }
+- (I*) Meth1 { return reinterpret_cast<I*>(delegate); }
+@end
+
OpenPOWER on IntegriCloud