]> granicus.if.org Git - clang/commitdiff
More tests for Objective-C-related name lookup weirdness. Yes, it's
authorDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 19:10:40 +0000 (19:10 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 19 Apr 2010 19:10:40 +0000 (19:10 +0000)
weird; yes, it's what GCC does. Almost.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101803 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaObjC/ivar-lookup.m
test/SemaObjCXX/ivar-lookup.mm [new file with mode: 0644]

index 644b3b638c92b88c41c890587615bc33eca945a7..06e47116f73ca23ad8c733f707fedfd7504b9109 100644 (file)
@@ -16,3 +16,22 @@ extern struct foo x;
 }
 
 @end
+
+@interface Ivar
+- (float*)method;
+@end
+
+@interface A {
+  A *Ivar;
+}
+- (int*)method;
+@end
+
+@implementation A
+- (int*)method {
+  int *ip = [Ivar method]; // expected-warning{{warning: incompatible pointer types initializing 'int *' with an expression of type 'float *'}}
+                           // Note that there is no warning in Objective-C++
+  return 0;
+}
+@end
+
diff --git a/test/SemaObjCXX/ivar-lookup.mm b/test/SemaObjCXX/ivar-lookup.mm
new file mode 100644 (file)
index 0000000..bb26f48
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface Ivar
+- (float*)method;
+@end
+
+@interface A {
+  A *Ivar;
+}
+- (int*)method;
+@end
+
+@implementation A
+- (int*)method {
+  int *ip = [Ivar method]; // Okay; calls A's method on the instance variable Ivar.
+                           // Note that Objective-C calls Ivar's method.
+  return 0;
+}
+@end