From: Douglas Gregor Date: Mon, 19 Apr 2010 19:10:40 +0000 (+0000) Subject: More tests for Objective-C-related name lookup weirdness. Yes, it's X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7174f2924a18e6e6754575d80db405aac9168c8;p=clang More tests for Objective-C-related name lookup weirdness. Yes, it's 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 --- diff --git a/test/SemaObjC/ivar-lookup.m b/test/SemaObjC/ivar-lookup.m index 644b3b638c..06e47116f7 100644 --- a/test/SemaObjC/ivar-lookup.m +++ b/test/SemaObjC/ivar-lookup.m @@ -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 index 0000000000..bb26f48f13 --- /dev/null +++ b/test/SemaObjCXX/ivar-lookup.mm @@ -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