brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · fda8228 Raw
122 lines · plain
1// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s2 3__attribute__((unavailable("not available")))4@interface MyClass { // expected-note 7 {{'MyClass' has been explicitly marked unavailable here}}5@public6    void *_test;7    MyClass *ivar; // no error.8}9 10- (id)self;11- new;12+ (void)addObject:(id)anObject;13- (MyClass *)meth; // no error.14 15@end16 17@interface Gorf {18  MyClass *ivar; // expected-error {{unavailable}}19}20- (MyClass *)meth; // expected-error {{unavailable}}21@end22 23@interface MyClass (Cat1)24- (MyClass *)meth; // no error.25@end26 27@interface MyClass (Cat2) // no error.28@end29 30@implementation MyClass (Cat2) // no error.31@end32 33int main(void) {34 [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}35 [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}36 [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}37 38 MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}}39 40 return 0;41}42 43@interface NSObject @end44 45__attribute__((visibility("default"))) __attribute__((availability(macosx,unavailable)))46@interface Foo : NSObject @end // expected-note 3 {{'Foo' has been explicitly marked unavailable here}}47@interface AppDelegate  : NSObject48@end49 50@class Foo;51 52@implementation AppDelegate53- (void) applicationDidFinishLaunching54{55  Foo *foo = 0; // expected-error {{'Foo' is unavailable}}56}57@end58 59@class Foo;60Foo *g_foo = 0; // expected-error {{'Foo' is unavailable}}61 62@class Foo;63@class Foo;64@class Foo;65Foo * f_func(void) { // expected-error {{'Foo' is unavailable}}66  return 0; 67}68 69#define UNAVAILABLE __attribute__((unavailable("not available")))70 71UNAVAILABLE72@interface Base // expected-note {{unavailable here}}73@end74 75UNAVAILABLE76@protocol SomeProto // expected-note 4 {{unavailable here}}77@end78 79@interface Sub : Base<SomeProto> // expected-error 2 {{unavailable}}80@end81@interface IP<SomeProto> // expected-error {{unavailable}}82@end83@protocol SubProt<SomeProto> // expected-error {{unavailable}}84@end85@interface Sub(cat)<SomeProto> // expected-error {{unavailable}}86@end87 88UNAVAILABLE89@interface UnavailSub : Base<SomeProto> // no error90@end91UNAVAILABLE92@interface UnavailIP<SomeProto> // no error93@end94UNAVAILABLE95@protocol UnavailProt<SomeProto> // no error96@end97@interface UnavailSub(cat)<SomeProto> // no error98@end99 100int unavail_global UNAVAILABLE;101 102UNAVAILABLE __attribute__((objc_root_class))103@interface TestAttrContext104-meth;105@end106 107@implementation TestAttrContext108-meth {109  unavail_global = 2; // no warn110  (void) ^{111    unavail_global = 4; // no warn112  };113}114@end115 116typedef int unavailable_int UNAVAILABLE; // expected-note {{'unavailable_int' has been explicitly marked unavailable here}}117 118UNAVAILABLE119@interface A120extern unavailable_int global_unavailable; // expected-error {{'unavailable_int' is unavailable: not available}}121@end122