Skip to content

[5.0] [Driver] Don't suggest using the "major version" for -swift-version #21169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ ERROR(error_no_source_location_scope_map,none,
"-dump-scope-maps argument must be 'expanded' or a list of "
"source locations", ())

NOTE(note_swift_version_major, none,
"use major version, as in '-swift-version %0'", (unsigned))
NOTE(note_valid_swift_versions, none,
"valid arguments to '-swift-version' are %0", (StringRef))

Expand Down
16 changes: 4 additions & 12 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,10 @@ static void diagnoseSwiftVersion(Optional<version::Version> &vers, Arg *verArg,
diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
verArg->getAsString(Args), verArg->getValue());

// Check for an unneeded minor version, otherwise just list valid versions
if (vers.hasValue() && !vers.getValue().empty() &&
vers.getValue().asMajorVersion().getEffectiveLanguageVersion()) {
diags.diagnose(SourceLoc(), diag::note_swift_version_major,
vers.getValue()[0]);
} else {
// Note valid versions instead
auto validVers = version::Version::getValidEffectiveVersions();
auto versStr =
"'" + llvm::join(validVers.begin(), validVers.end(), "', '") + "'";
diags.diagnose(SourceLoc(), diag::note_valid_swift_versions, versStr);
}
// Note valid versions.
auto validVers = version::Version::getValidEffectiveVersions();
auto versStr = "'" + llvm::join(validVers, "', '") + "'";
diags.diagnose(SourceLoc(), diag::note_valid_swift_versions, versStr);
}

/// \brief Create a new Regex instance out of the string value in \p RpassArg.
Expand Down
8 changes: 2 additions & 6 deletions test/Driver/swift-version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
// RUN: not %target-swiftc_driver -swift-version 7.2 %s 2>&1 | %FileCheck --check-prefix BAD %s
// RUN: not %target-swiftc_driver -swift-version 3.0 %s 2>&1 | %FileCheck --check-prefix BAD %s
// RUN: not %target-swiftc_driver -swift-version 3.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
// RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix FIXIT_4 %s
// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix FIXIT_5 %s
// RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix BAD %s

// RUN: not %target-swiftc_driver -swift-version 4 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_4 %s
// RUN: not %target-swiftc_driver -swift-version 5 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_5 %s

// BAD: invalid value
// BAD: note: valid arguments to '-swift-version' are '4', '4.2', '5'

// FIXIT_4: use major version, as in '-swift-version 4'
// FIXIT_5: use major version, as in '-swift-version 5'


#if swift(>=3)
asdf
// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
Expand Down