Skip to content

Commit 4923db8

Browse files
committed
Adjust PlatformConditionKinds.def + target #objectFormat test more precisely
1 parent c3f865b commit 4923db8

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

include/swift/AST/PlatformConditionKinds.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PLATFORM_CONDITION_(PtrAuth, "ptrauth")
5050
PLATFORM_CONDITION_(HasAtomicBitWidth, "hasAtomicBitWidth")
5151

5252
/// The active target's file format (Mach-O, ELF, COFF, WASM)
53-
PLATFORM_CONDITION_(ObjectFileFormat, "objectFormat")
53+
PLATFORM_CONDITION(ObjectFileFormat, "objectFormat")
5454

5555
#undef PLATFORM_CONDITION
5656
#undef PLATFORM_CONDITION_
Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
// RUN: %swift -typecheck %s -verify -target arm64-apple-none-macho -parse-stdlib
2-
// RUN: %swift -typecheck %s -verify -target arm64-apple-none-elf -parse-stdlib
3-
// RUN: %swift -typecheck %s -verify -target wasm32-unknown-wasi -parse-stdlib
4-
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-windows-msvc -parse-stdlib
5-
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target arm64-apple-macos
1+
// RUN: %swift -typecheck %s -target arm64-apple-none-macho -parse-stdlib 2>&1 | %FileCheck -check-prefix CHECK-MACHO %s
2+
// RUN: %swift -typecheck %s -target arm64-apple-none-elf -parse-stdlib 2>&1 | %FileCheck -check-prefix CHECK-ELF %s
3+
// RUN: %swift -typecheck %s -target wasm32-unknown-wasi -parse-stdlib 2>&1 | %FileCheck -check-prefix CHECK-WASM %s
4+
// RUN: %swift -typecheck %s -target x86_64-unknown-windows-msvc -parse-stdlib 2>&1 | %FileCheck -check-prefix CHECK-COFF %s
65

7-
#if objectFormat(MachO) || objectFormat(ELF) || objectFormat(Wasm) || objectFormat(COFF)
8-
class C {}
9-
var x = C()
6+
#if objectFormat(MachO)
7+
#warning("I'm MachO")
8+
#else
9+
#warning("I'm not MachO")
1010
#endif
11-
var y = x
11+
12+
#if objectFormat(ELF)
13+
#warning("I'm ELF")
14+
#else
15+
#warning("I'm not ELF")
16+
#endif
17+
18+
#if objectFormat(Wasm)
19+
#warning("I'm Wasm")
20+
#else
21+
#warning("I'm not Wasm")
22+
#endif
23+
24+
#if objectFormat(COFF)
25+
#warning("I'm COFF")
26+
#else
27+
#warning("I'm not COFF")
28+
#endif
29+
30+
// CHECK-MACHO: I'm MachO
31+
// CHECK-MACHO: I'm not ELF
32+
// CHECK-MACHO: I'm not Wasm
33+
// CHECK-MACHO: I'm not COFF
34+
35+
// CHECK-ELF: I'm not MachO
36+
// CHECK-ELF: I'm ELF
37+
// CHECK-ELF: I'm not Wasm
38+
// CHECK-ELF: I'm not COFF
39+
40+
// CHECK-WASM: I'm not MachO
41+
// CHECK-WASM: I'm not ELF
42+
// CHECK-WASM: I'm Wasm
43+
// CHECK-WASM: I'm not COFF
44+
45+
// CHECK-COFF: I'm not MachO
46+
// CHECK-COFF: I'm not ELF
47+
// CHECK-COFF: I'm not Wasm
48+
// CHECK-COFF: I'm COFF

0 commit comments

Comments
 (0)