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