mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When we encounter a check like `#if compiler(>=6.0) && something` or `#if swift(<6.0) || something`, and the left-hand term is a versioning check that determines the result of the whole condition, then we will not attempt to validate the right-hand term. This allows us to use versioned checks along with new discovery features (say, if we add an `#if attribute(x)`) without having to next conditions.
29 lines
747 B
Swift
29 lines
747 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// expected-error@+1{{unexpected platform condition}}
|
|
#if hasGreeble(blah)
|
|
#endif
|
|
|
|
// Future compiler, short-circuit right-hand side
|
|
#if compiler(>=10.0) && hasGreeble(blah)
|
|
#endif
|
|
|
|
// Current compiler, short-circuit right-hand side
|
|
#if compiler(<10.0) || hasGreeble(blah)
|
|
#endif
|
|
|
|
// This compiler, don't short-circuit.
|
|
// expected-error@+1{{unexpected platform condition}}
|
|
#if compiler(>=5.7) && hasGreeble(blah)
|
|
#endif
|
|
|
|
// This compiler, don't short-circuit.
|
|
// expected-error@+1{{unexpected platform condition}}
|
|
#if compiler(<5.8) || hasGreeble(blah)
|
|
#endif
|
|
|
|
// Not a "version" check, so don't short-circuit.
|
|
// expected-error@+1{{unexpected platform condition}}
|
|
#if os(macOS) && hasGreeble(blah)
|
|
#endif
|