#define AVAILABLE_10_0 __attribute__((availability(macos, introduced = 10.0)))
#define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
#define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
typedef int AVAILABLE_10_12 new_int;
int func_10_11(void) AVAILABLE_10_11;
#ifdef OBJCPP
#endif
int func_10_12(void) AVAILABLE_10_12;
int func_10_0(void) AVAILABLE_10_0;
void use_func(void) {
func_10_11();
if (@available(macos 10.11, *))
func_10_11();
else
func_10_11(); }
void defn_10_11(void) AVAILABLE_10_11;
void defn_10_11(void) {
func_10_11();
}
void nested_ifs(void) {
if (@available(macos 10.12, *)) {
if (@available(macos 10.10, *)) {
func_10_12();
} else {
func_10_12();
}
} else {
func_10_12(); }
}
void star_case(void) {
if (@available(ios 9, *)) {
func_10_11(); func_10_0();
} else
func_10_11();
if (@available(macOS 10.11, *)) {
if (@available(ios 8, *)) {
func_10_11();
func_10_12(); } else {
func_10_11();
func_10_12(); }
}
}
typedef int int_10_11 AVAILABLE_10_11; #ifdef OBJCPP
#endif
typedef int int_10_12 AVAILABLE_10_12;
void use_typedef(void) {
int_10_11 x; }
__attribute__((objc_root_class))
AVAILABLE_10_11 @interface Class_10_11 { int_10_11 foo;
int_10_12 bar; }
- (void)method1;
- (void)method2;
@end
@implementation Class_10_11
- (void) method1 {
func_10_11();
func_10_12(); }
- (void)method2 AVAILABLE_10_12 {
func_10_12();
}
@end
int protected_scope(void) {
if (@available(macos 10.20, *)) { label1:
return 0;
} else {
label2:
goto label1; }
goto label2; }
struct S {
int m1;
int m2 __attribute__((availability(macos, introduced = 10.12)));
struct Nested {
int nested_member __attribute__((availability(macos, introduced = 10.12))); } n;
};
int test_members(void) {
struct S s;
(void)s.m1;
(void)s.m2;
(void)s.n.nested_member; }
void test_blocks(void) {
(void) ^{
func_10_12(); };
if (@available(macos 10.12, *))
(void) ^{
func_10_12();
(void) ^{
func_10_12();
};
};
}
void test_params(int_10_12 x);
void test_params2(int_10_12 x) AVAILABLE_10_12;
void (^topLevelBlockDecl)(void) = ^ {
func_10_12(); if (@available(macos 10.12, *))
func_10_12();
};
AVAILABLE_10_12
__attribute__((objc_root_class))
@interface InterWithProp @property(class) int x;
+ (void) setX: (int)newX AVAILABLE_10_12; @end
void test_property(void) {
int y = InterWithProp.x; InterWithProp.x = y; }
__attribute__((objc_root_class))
@interface Subscriptable
- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; @end
void test_at(Subscriptable *x) {
id y = x[42]; }
void uncheckAtAvailable(void) {
if (@available(macOS 10.12, *) || 0) func_10_12(); }
void justAtAvailable(void) {
int availability = @available(macOS 10.12, *); }
#ifdef OBJCPP
int f(char) AVAILABLE_10_12;
int f(int);
template <class T> int use_f() {
return f(T());
}
int a = use_f<int>();
int b = use_f<char>();
template <class> int use_at_available() {
if (@available(macos 10.12, *))
return func_10_12();
else
return func_10_12(); }
int instantiate_template() {
if (@available(macos 10.12, *)) {
use_at_available<char>();
} else {
use_at_available<float>();
}
}
template <class>
int with_availability_attr() AVAILABLE_10_11 { return 0;
}
int instantiate_with_availability_attr() {
if (@available(macos 10.12, *))
with_availability_attr<char>();
else
with_availability_attr<int>(); }
int instantiate_availability() {
if (@available(macOS 10.12, *))
with_availability_attr<int_10_12>();
else
with_availability_attr<int_10_12>(); }
auto topLevelLambda = [] () {
func_10_12(); if (@available(macos 10.12, *))
func_10_12();
};
void functionInFunction() {
func_10_12(); struct DontWarnTwice {
void f() {
func_10_12(); }
};
void([] () {
func_10_12(); });
(void)(^ {
func_10_12(); });
if (@available(macos 10.12, *)) {
void([]() {
func_10_12();
void([] () {
func_10_12();
});
struct DontWarn {
void f() {
func_10_12();
}
};
});
}
if (@available(macos 10.12, *)) {
struct DontWarn {
void f() {
func_10_12();
void([] () {
func_10_12();
});
struct DontWarn2 {
void f() {
func_10_12();
}
};
}
};
}
}
#endif
struct InStruct { new_int mem;
struct { new_int mem; } anon; };
#ifdef OBJCPP
static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; typedef enum { SomeValue = SomeConstexprValue } SomeEnum;
#endif
@interface InInterface
-(new_int)meth; @end
@interface Proper @property (class) new_int x; @end
void with_local_struct(void) {
struct local {
new_int x; };
if (@available(macos 10.12, *)) {
struct DontWarn {
new_int x;
};
}
}
AVAILABLE_10_12
@protocol NewProtocol @end
@protocol ProtocolWithNewProtocolRequirement <NewProtocol>
@property(copy) id<NewProtocol> prop;
@end
@interface BaseClass
@end
@interface ClassWithNewProtocolRequirement : BaseClass <NewProtocol>
@end
@interface BaseClass (CategoryWithNewProtocolRequirement) <NewProtocol>
@end
typedef enum {
AK_Dodo __attribute__((availability(macos, deprecated=10.3))), AK_Cat __attribute__((availability(macos, introduced=10.4))),
AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), } Animals;
void switchAnimals(Animals a) {
switch (a) {
case AK_Dodo: break; case AK_Cat: break;
case AK_Cat|AK_CyborgCat: break; case AK_CyborgCat: break; }
switch (a) {
case AK_Dodo...AK_CyborgCat: break;
}
(void)AK_Dodo; (void)AK_Cat; (void)AK_CyborgCat; }
@interface HasStaticInitializer : BaseClass
+ (void)load AVAILABLE_10_11; @end
@implementation HasStaticInitializer
+ (void)load {
func_10_11(); }
@end
AVAILABLE_10_11
@interface HasStaticInitializer1 : BaseClass
+ (void)load;
+ (void)load: (int)x; @end
@implementation HasStaticInitializer1
+ (void)load {
func_10_11(); }
+ (void)load: (int)x {
func_10_11(); }
@end
__attribute__((constructor))
void is_constructor(void);
AVAILABLE_10_11 void is_constructor(void) {
func_10_11(); }
AVAILABLE_10_11 __attribute__((destructor))
void is_destructor(void) {
func_10_11(); }