Files
swift-mirror/test/Parse/unknown_platform.swift
Doug Gregor 2da25612ba Short-circuit validation of #if conditions after a versioned check.
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.
2022-07-19 21:27:54 -07:00

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