mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
"-swift-version 3" means Swift 3.1, not 3.0. (#7883)
Put in a general mechanism for mapping user-specified "compatibility versions" to proper "effective versions" (what #if and @available checking should respect). This may still be different from the intrinsic "language version"; right now master is considered a "3.1" compiler with a "Swift 4 mode", and we plan to ship a "4.0" compiler with a "Swift 3 mode" that will have a version number of something like "3.2". rdar://problem/29884401 / SR-3791
This commit is contained in:
@@ -802,7 +802,7 @@ static void diagnoseSwiftVersion(Optional<version::Version> &vers, Arg *verArg,
|
||||
|
||||
// Check for an unneeded minor version, otherwise just list valid versions
|
||||
if (vers.hasValue() && !vers.getValue().empty() &&
|
||||
vers.getValue().asMajorVersion().isValidEffectiveLanguageVersion()) {
|
||||
vers.getValue().asMajorVersion().getEffectiveLanguageVersion()) {
|
||||
diags.diagnose(SourceLoc(), diag::note_swift_version_major,
|
||||
vers.getValue()[0]);
|
||||
} else {
|
||||
@@ -822,12 +822,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
if (auto A = Args.getLastArg(OPT_swift_version)) {
|
||||
auto vers = version::Version::parseVersionString(
|
||||
A->getValue(), SourceLoc(), &Diags);
|
||||
if (vers.hasValue() &&
|
||||
vers.getValue().isValidEffectiveLanguageVersion()) {
|
||||
Opts.EffectiveLanguageVersion = vers.getValue();
|
||||
} else {
|
||||
diagnoseSwiftVersion(vers, A, Args, Diags);
|
||||
bool isValid = false;
|
||||
if (vers.hasValue()) {
|
||||
if (auto effectiveVers = vers.getValue().getEffectiveLanguageVersion()) {
|
||||
Opts.EffectiveLanguageVersion = effectiveVers.getValue();
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
if (!isValid)
|
||||
diagnoseSwiftVersion(vers, A, Args, Diags);
|
||||
}
|
||||
|
||||
Opts.AttachCommentsToDecls |= Args.hasArg(OPT_dump_api_path);
|
||||
|
||||
Reference in New Issue
Block a user