summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjC/message.m
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjC/message.m
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjC/message.m')
-rw-r--r--clang/test/SemaObjC/message.m100
1 files changed, 100 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/message.m b/clang/test/SemaObjC/message.m
new file mode 100644
index 0000000..621a18f
--- /dev/null
+++ b/clang/test/SemaObjC/message.m
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@interface foo
+- (void)meth;
+@end
+
+@implementation foo
+- (void) contents {} // No declaration in @interface!
+- (void) meth { [self contents]; }
+@end
+
+typedef struct _NSPoint {
+ float x;
+ float y;
+} NSPoint;
+
+typedef struct _NSSize {
+ float width;
+ float height;
+} NSSize;
+
+typedef struct _NSRect {
+ NSPoint origin;
+ NSSize size;
+} NSRect;
+
+@interface AnyClass
+- (NSRect)rect;
+@end
+
+@class Helicopter;
+
+static void func(Helicopter *obj) {
+ // Note that the proto for "rect" is found in the global pool even when
+ // a statically typed object's class interface isn't in scope! This
+ // behavior isn't very desirable, however wee need it for GCC compatibility.
+ NSRect r = [obj rect];
+}
+
+@interface NSObject @end
+
+extern Class NSClassFromObject(id object);
+
+@interface XX : NSObject
+@end
+
+@implementation XX
+
++ _privateMethod {
+ return self;
+}
+
+- (void) xx {
+ [NSClassFromObject(self) _privateMethod];
+}
+@end
+
+@implementation XX (Private)
+- (void) yy {
+ [NSClassFromObject(self) _privateMethod];
+}
+@end
+
+@interface I0
+-(void) nonVararg: (int) x;
+@end
+
+int f0(I0 *ob) {
+ [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
+}
+
+int f2() {
+ const id foo;
+ [foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}}
+ return 0;
+}
+
+
+// PR3766
+struct S { int X; } S;
+
+int test5(int X) {
+ int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \
+ expected-warning {{method '-somemsg' not found}} \
+ expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
+ int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}}
+}
+
+// PR4021
+void foo4() {
+ struct objc_object X[10];
+
+ [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} expected-warning {{method '-rect' not found (return type defaults to 'id')}}
+}
+