Skip to content

Commit ef7dd0f

Browse files
authored
[Driver] Don't suggest using the "major version" for -swift-version (#21169)
This was a nice feature when people said "-swift-version 3.1"... up until we got "-swift-version 4.2" as an actual valid version. Just drop the special case. https://bugs.swift.org/browse/SR-8850 (cherry picked from commit 00ed3e1)
1 parent 930667e commit ef7dd0f

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ ERROR(error_no_source_location_scope_map,none,
103103
"-dump-scope-maps argument must be 'expanded' or a list of "
104104
"source locations", ())
105105

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

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,10 @@ static void diagnoseSwiftVersion(Optional<version::Version> &vers, Arg *verArg,
100100
diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
101101
verArg->getAsString(Args), verArg->getValue());
102102

103-
// Check for an unneeded minor version, otherwise just list valid versions
104-
if (vers.hasValue() && !vers.getValue().empty() &&
105-
vers.getValue().asMajorVersion().getEffectiveLanguageVersion()) {
106-
diags.diagnose(SourceLoc(), diag::note_swift_version_major,
107-
vers.getValue()[0]);
108-
} else {
109-
// Note valid versions instead
110-
auto validVers = version::Version::getValidEffectiveVersions();
111-
auto versStr =
112-
"'" + llvm::join(validVers.begin(), validVers.end(), "', '") + "'";
113-
diags.diagnose(SourceLoc(), diag::note_valid_swift_versions, versStr);
114-
}
103+
// Note valid versions.
104+
auto validVers = version::Version::getValidEffectiveVersions();
105+
auto versStr = "'" + llvm::join(validVers, "', '") + "'";
106+
diags.diagnose(SourceLoc(), diag::note_valid_swift_versions, versStr);
115107
}
116108

117109
/// \brief Create a new Regex instance out of the string value in \p RpassArg.

test/Driver/swift-version.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@
66
// RUN: not %target-swiftc_driver -swift-version 7.2 %s 2>&1 | %FileCheck --check-prefix BAD %s
77
// RUN: not %target-swiftc_driver -swift-version 3.0 %s 2>&1 | %FileCheck --check-prefix BAD %s
88
// RUN: not %target-swiftc_driver -swift-version 3.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
9-
// RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix FIXIT_4 %s
10-
// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix FIXIT_5 %s
9+
// RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
10+
// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix BAD %s
1111

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

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

18-
// FIXIT_4: use major version, as in '-swift-version 4'
19-
// FIXIT_5: use major version, as in '-swift-version 5'
20-
21-
2218
#if swift(>=3)
2319
asdf
2420
// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}}

0 commit comments

Comments
 (0)