1*396f40a7SNico Weber // RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-macos -DMAC -verify %s 2*396f40a7SNico Weber // RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios13.1 -DIOS -verify %s 3*396f40a7SNico Weber // RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios13.1-macabi -DCATALYST -verify %s 4*396f40a7SNico Weber // RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-macos12 -darwin-target-variant-triple arm64-apple-ios-macabi -DZIPPERED -verify %s 5*396f40a7SNico Weber // expected-no-diagnostics 6*396f40a7SNico Weber 7*396f40a7SNico Weber #if !__has_builtin(__is_target_variant_os) || !__has_builtin(__is_target_variant_environment) 8*396f40a7SNico Weber #error "has builtin doesn't work" 9*396f40a7SNico Weber #endif 10*396f40a7SNico Weber 11*396f40a7SNico Weber #ifdef ZIPPERED 12*396f40a7SNico Weber 13*396f40a7SNico Weber // Target variant is a darwin. 14*396f40a7SNico Weber #if !__is_target_variant_os(darwin) 15*396f40a7SNico Weber #error "mismatching variant os" 16*396f40a7SNico Weber #endif 17*396f40a7SNico Weber 18*396f40a7SNico Weber // Target variant is not macOS... 19*396f40a7SNico Weber #if __is_target_variant_os(macos) 20*396f40a7SNico Weber #error "mismatching variant os" 21*396f40a7SNico Weber #endif 22*396f40a7SNico Weber 23*396f40a7SNico Weber // ...but iOS. 24*396f40a7SNico Weber #if !__is_target_variant_os(ios) 25*396f40a7SNico Weber #error "mismatching variant os" 26*396f40a7SNico Weber #endif 27*396f40a7SNico Weber 28*396f40a7SNico Weber // Zippered builds also set the target variant environment to macabi. 29*396f40a7SNico Weber // At the moment, only zippered builds set __is_target_variant_os(ios), 30*396f40a7SNico Weber // so checking __is_target_variant_environment() is currently redundant 31*396f40a7SNico Weber // with checking the former. 32*396f40a7SNico Weber #if !__is_target_variant_environment(macabi) 33*396f40a7SNico Weber #error "mismatching variant environment" 34*396f40a7SNico Weber #endif 35*396f40a7SNico Weber 36*396f40a7SNico Weber #else 37*396f40a7SNico Weber 38*396f40a7SNico Weber // In non-zippered builds, even for catalyst, no target variant is set. 39*396f40a7SNico Weber // So these are all false. 40*396f40a7SNico Weber 41*396f40a7SNico Weber #if __is_target_variant_os(darwin) 42*396f40a7SNico Weber #error "mismatching variant os" 43*396f40a7SNico Weber #endif 44*396f40a7SNico Weber 45*396f40a7SNico Weber #if __is_target_variant_os(macos) 46*396f40a7SNico Weber #error "mismatching variant os" 47*396f40a7SNico Weber #endif 48*396f40a7SNico Weber 49*396f40a7SNico Weber #if __is_target_variant_os(ios) 50*396f40a7SNico Weber #error "mismatching variant os" 51*396f40a7SNico Weber #endif 52*396f40a7SNico Weber 53*396f40a7SNico Weber #if __is_target_variant_environment(macabi) 54*396f40a7SNico Weber #error "mismatching variant environment" 55*396f40a7SNico Weber #endif 56*396f40a7SNico Weber 57*396f40a7SNico Weber #endif 58*396f40a7SNico Weber 59*396f40a7SNico Weber // The target environment in zippered builds is _not_ macabi. 60*396f40a7SNico Weber // The target environment is macabi only in catalyst builds. 61*396f40a7SNico Weber #ifdef CATALYST 62*396f40a7SNico Weber #if !__is_target_environment(macabi) 63*396f40a7SNico Weber #error "mismatching environment" 64*396f40a7SNico Weber #endif 65*396f40a7SNico Weber #if !__is_target_os(ios) 66*396f40a7SNico Weber #error "mismatching os" 67*396f40a7SNico Weber #endif 68*396f40a7SNico Weber #else 69*396f40a7SNico Weber #if __is_target_environment(macabi) 70*396f40a7SNico Weber #error "mismatching environment" 71*396f40a7SNico Weber #endif 72*396f40a7SNico Weber #endif 73