-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
569859a
commit 2da2561
Showing
2 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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 |