mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add "-swift-version <n>" that sets LangOpts.EffectiveLanguageVersion.
This flag switches the "effective language version" of the compiler, at least to any version supported (as of this change: "3" or "3.0"). At the moment nothing uses it except the language version build configuration statements (#if swift(...)) and various other places that report, encode, or otherwise check version numbers. In the future, it's intended as scaffolding for backwards compatibility. Fixes SR-2582
This commit is contained in:
@@ -765,6 +765,18 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
const FrontendOptions &FrontendOpts) {
|
||||
using namespace options;
|
||||
|
||||
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 {
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
|
||||
A->getAsString(Args), A->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Opts.AttachCommentsToDecls |= Args.hasArg(OPT_dump_api_path);
|
||||
|
||||
Opts.UseMalloc |= Args.hasArg(OPT_use_malloc);
|
||||
|
||||
Reference in New Issue
Block a user