From c1fcd2c3bfbee96374654c80a2aa1af455e0de4e Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Sat, 21 Feb 2009 17:03:43 +0000 Subject: [PATCH] Add test case to record a couple inconsistencies with GCC (found in [clang on Xcode] warning: cannot find protocol definition for 'OzzyP'). Removing the "cannot find protocol" warning is trivial if necessary (but I don't think it's the right thing to do). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65232 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaObjC/protocol-undef.m | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/SemaObjC/protocol-undef.m diff --git a/test/SemaObjC/protocol-undef.m b/test/SemaObjC/protocol-undef.m new file mode 100644 index 0000000000..c35d3f8636 --- /dev/null +++ b/test/SemaObjC/protocol-undef.m @@ -0,0 +1,47 @@ +// RUN: clang -fsyntax-only -verify %s + +typedef signed char BOOL; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject +- (BOOL)isEqual:(id)object; +@end +@protocol NSCoding +- (void)encodeWithCoder:(NSCoder *)aCoder; +@end +@interface NSObject {} @end +@class NSArray, NSAttributedString, NSEvent, NSInputServer, NSImage; +@interface NSController : NSObject {} @end +@class OzzyView; +typedef struct _OzzyInset {} OzzyInset; +@protocol OzzyP; +typedef NSObject Ozzy; +@protocol OzzyAnchorP; +typedef NSObject OzzyAnchor; +@protocol OzzyAnchorDelegateP +- (BOOL)anchor:(OzzyAnchor *)anchor confirmRepresentedObject:(id)newObject; +@end +typedef NSObject OzzyAnchorDelegate; +// GCC doesn't warn about the following (which is inconsistent with it's handling of @interface below). +@protocol OzzyAnchorP // expected-warning{{cannot find protocol definition for 'OzzyP'}} + @property(nonatomic,retain) id representedObject; + @property(nonatomic,retain) Ozzy * contentGroup; +@end +@interface XXX : NSObject // expected-warning{{cannot find protocol definition for 'OzzyP'}} +@end +@protocol OzzyActionDelegateP + @optional - (BOOL)elementView:(OzzyView *)elementView shouldDragElement:(Ozzy *)element; +@end +typedef NSObject OzzyActionDelegate; +@interface OzzyUnit : OzzyAnchorDelegate {} +@end +@interface OzzyArrayUnit : OzzyUnit {} @end +@implementation OzzyArrayUnit +- (BOOL)willChangeLayoutForObjects:(NSArray *)objects fromObjects:(NSArray *)oldObjects {} +- (void)_recalculateStoredArraysForAnchor:(OzzyAnchor *)anchor { + Ozzy * contentGroup = anchor.contentGroup; + if (contentGroup == ((void *)0)) { + // GCC doesn't warn about the following (which seems wrong). + contentGroup = anchor; // expected-warning{{incompatible pointer types assigning 'OzzyAnchor *', expected 'Ozzy *'}} + } +} +@end -- 2.40.0