forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Suppress warning about useless availability checks in playgrou…
…nds and immediate mode. We normally report a warning when a #available() check will always be true because of the minimum deployment target. These warnings are potentially annoying when the developer either cannot change the minimum deployment target from the default (as in playgrounds) or when doing so is burdensome (as for interpreted command-line scripts, which would require passing a target triple) -- so suppress them. The is a updated version of the reverted r29582, which didn't check for immediate mode properly. rdar://problem/21324005 Swift SVN r29646
- Loading branch information
1 parent
786141f
commit 3e96e1f
Showing
5 changed files
with
96 additions
and
28 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
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
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,36 @@ | ||
// Playgrounds | ||
// RUN: %target-parse-verify-swift -playground | ||
|
||
// Immediate mode | ||
// RUN: %target-parse-verify-swift -interpret | ||
|
||
// REQUIRES: OS=macosx | ||
// REQUIRES: swift_interpreter | ||
|
||
func someFunction() { | ||
// We would normally emit a warning indicating this check is useless (because | ||
// the minimum deployment target is 10.9) -- but do not when compiling for | ||
// playgrounds because the developer cannot set the minimum deployment target | ||
// herself. We also suppress this warning when compiling in immediate mode. | ||
if #available(OSX 10.8, *) { | ||
} | ||
|
||
if #available(OSX 10.11, *) { // expected-note {{enclosing scope here}} | ||
// Still warn if the check is useless because an enclosing #available rules | ||
// it out. | ||
if #available(OSX 10.11, *) { // expected-warning {{unnecessary check for 'OSX'; enclosing scope ensures guard will always be true}} | ||
} | ||
} | ||
} | ||
|
||
@available(OSX 10.11, *) | ||
func availableOn10_11() { // expected-note {{enclosing scope here}} | ||
// Still warn if the check is useless because an enclosing @available rules | ||
// it out. | ||
if #available(OSX 10.11, *) { // expected-warning {{unnecessary check for 'OSX'; enclosing scope ensures guard will always be true}} | ||
} | ||
} | ||
|
||
// Make sure we don't warn at the top level | ||
if #available(OSX 10.8, *) { | ||
} |