mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
For the most part, the differences between the diagnostics introduced
by the C++ implementation and the new SwiftIfConfig implementation are
cosmetic, so these are only wording changes.
The one major difference is that we've dropped the warnings about
potential typos in os/arch checks. For example, if one writes:
#if os(bisionos)
// ...
#endif
The C++ implementation will produce a warning "unknown operating system
for build configuration 'os'" with a note asking "did you mean
'visionOS'"? These warnings rely on a static list of known operating
systems and architectures, which is somewhat unfortunate: the whole
point of these checks is that the Swift you're dealing with might not
have support for those operating systems/architectures, so while these
warnings can be helpful in a few cases, they also cause false
positives when porting. Therefore, I chose not to bring them forward.
45 lines
1.8 KiB
Swift
45 lines
1.8 KiB
Swift
// RUN: %swift -swift-version 4 -typecheck %s -verify -target x86_64-apple-ios7.0-simulator -parse-stdlib
|
|
// RUN: %swift -swift-version 4 -typecheck %s -verify -target x86_64-unknown-linux-simulator -parse-stdlib
|
|
// RUN: %swift-ide-test -swift-version 4 -test-input-complete -source-filename=%s -target x86_64-apple-ios7.0-simulator
|
|
|
|
#if !targetEnvironment(simulator)
|
|
// This block should not parse.
|
|
let i: Int = "Hello"
|
|
#endif
|
|
|
|
#if targetEnvironment(simulator)
|
|
class C {}
|
|
var x = C()
|
|
#endif
|
|
var y = x
|
|
|
|
#if os(iOS) && arch(i386)
|
|
// expected-warning @-1 {{platform condition appears to be testing for simulator environment}}
|
|
// expected-note@-2{{replace with 'targetEnvironment(simulator)'}}{{5-26=targetEnvironment(simulator)}}
|
|
class C1 {}
|
|
#endif
|
|
|
|
#if arch(i386) && os(iOS)
|
|
// expected-warning @-1 {{platform condition appears to be testing for simulator environment}}
|
|
// expected-note@-2{{replace with 'targetEnvironment(simulator)'}}{{5-26=targetEnvironment(simulator)}}
|
|
class C2 {}
|
|
#endif
|
|
|
|
#if arch(i386) && (os(iOS) || os(watchOS))
|
|
// expected-warning @-1 {{platform condition appears to be testing for simulator environment}}
|
|
// expected-note@-2{{replace with 'targetEnvironment(simulator)'}}{{5-43=targetEnvironment(simulator)}}
|
|
class C3 {}
|
|
#endif
|
|
|
|
#if (arch(x86_64) || arch(i386)) && (os(iOS) || os(watchOS) || os(tvOS))
|
|
// expected-warning @-1 {{platform condition appears to be testing for simulator environment}}
|
|
// expected-note@-2{{replace with 'targetEnvironment(simulator)'}}{{5-73=targetEnvironment(simulator)}}
|
|
class C4 {}
|
|
#endif
|
|
|
|
#if !(arch(x86_64) && os(tvOS))
|
|
// expected-warning @-1 {{platform condition appears to be testing for simulator environment}}
|
|
// expected-note@-2{{replace with 'targetEnvironment(simulator)'}}{{7-31=targetEnvironment(simulator)}}
|
|
class C5 {}
|
|
#endif
|