YouCompleteMe/cpp/llvm/tools/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
Strahinja Val Markovic 1f51a89d39 Adding more llvm/clang files
These were ignored by git accidentally. We want ALL OF THEM since they all came
in the llvm/clang source distribution.
2012-07-05 17:55:45 -07:00

89 lines
1.1 KiB
Plaintext

// 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.
if (object1 == object2)
[bar setBlah: object2]; // <== Does not compile. It should.
return 0;
}