[Version] Don't allow effective sub-versions, only major versions

Also offer a note when the major version is valid on its own.
This commit is contained in:
Michael Ilseman
2016-10-13 11:06:00 -07:00
parent db816f8a49
commit 12efcc9db6
8 changed files with 32 additions and 11 deletions

View File

@@ -773,8 +773,16 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
vers.getValue().isValidEffectiveLanguageVersion()) {
Opts.EffectiveLanguageVersion = vers.getValue();
} else {
// General invalid version error
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
// Check for an unneeded minor version
if (vers.hasValue() && !vers.getValue().empty() &&
vers.getValue().asMajorVersion().isValidEffectiveLanguageVersion()) {
Diags.diagnose(SourceLoc(), diag::note_swift_version_major,
vers.getValue()[0]);
}
}
}