Skip to content

Commit 1272cd3

Browse files
author
Ewa Matejska
committed
Making master call itself 4.1, updating the swift 3 compatiblity mode to be 3.3 (from 3.2), adding ability to pass swift-version 5. Importer work not done yet.
1 parent 31ad5b6 commit 1272cd3

File tree

12 files changed

+51
-16
lines changed

12 files changed

+51
-16
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
108108
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
109109
# can be reused when a new version of Swift comes out (assuming the user hasn't
110110
# manually set it as part of their own CMake configuration).
111-
set(SWIFT_VERSION "4.0")
111+
set(SWIFT_VERSION "4.1")
112112

113113
set(SWIFT_VENDOR "" CACHE STRING
114114
"The vendor name of the Swift compiler")

docs/Testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ FIXME: full list.
419419

420420
* ``optimized_stdlib_<CPUNAME>``: an optimized stdlib plus cpu configuration.
421421

422-
* ``SWIFT_VERSION=<MAJOR>``: restricts a test to Swift 3 or Swift 4. If you
422+
* ``SWIFT_VERSION=<MAJOR>``: restricts a test to Swift 3, Swift 4, Swift 5. If you
423423
need to use this, make sure to add a test for the other version as well
424424
unless you are specifically testing ``-swift-version``-related functionality.
425425

include/swift/AST/ASTContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,12 @@ class ASTContext {
865865

866866
/// Whether our effective Swift version is in the Swift 3 family
867867
bool isSwiftVersion3() const { return LangOpts.isSwiftVersion3(); }
868+
869+
/// Whether our effective Swift version is in the Swift 4 family
870+
bool isSwiftVersion4() const { return LangOpts.isSwiftVersion4(); }
871+
872+
/// Whether our effective Swift version is in the Swift 5 family
873+
bool isSwiftVersion5() const { return LangOpts.isSwiftVersion5(); }
868874

869875
private:
870876
friend Decl;

include/swift/Basic/LangOptions.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ namespace swift {
310310
bool isSwiftVersion3() const {
311311
return EffectiveLanguageVersion.isVersion3();
312312
}
313+
314+
/// Whether our effective Swift version is in the Swift 4 family
315+
bool isSwiftVersion4() const {
316+
return EffectiveLanguageVersion.isVersion4();
317+
}
318+
319+
/// Whether our effective Swift version is in the Swift 5 family
320+
bool isSwiftVersion5() const {
321+
return EffectiveLanguageVersion.isVersion5();
322+
}
313323

314324
/// Returns true if the given platform condition argument represents
315325
/// a supported target operating system.

include/swift/Basic/Version.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ class Version {
109109

110110
/// Whether this version is in the Swift 3 family
111111
bool isVersion3() const { return !empty() && Components[0] == 3; }
112+
113+
/// Whether this version is in the Swift 4 family
114+
bool isVersion4() const { return !empty() && Components[0] == 4; }
115+
116+
/// Whether this version is in the Swift 5 family
117+
bool isVersion5() const { return !empty() && Components[0] == 5; }
112118

113119
/// Return this Version struct with minor and sub-minor components stripped
114120
Version asMajorVersion() const;
@@ -137,8 +143,8 @@ class Version {
137143

138144
// Whitelist of backward-compatibility versions that we permit passing as
139145
// -swift-version <vers>
140-
static std::array<StringRef, 2> getValidEffectiveVersions() {
141-
return {{"3", "4"}};
146+
static std::array<StringRef, 3> getValidEffectiveVersions() {
147+
return {{"3", "4", "5"}};
142148
};
143149
};
144150

lib/Basic/Version.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,16 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
319319
switch (Components[0]) {
320320
case 3:
321321
#ifdef SWIFT_VERSION_PATCHLEVEL
322-
return Version{3, 2, SWIFT_VERSION_PATCHLEVEL};
322+
return Version{3, 3, SWIFT_VERSION_PATCHLEVEL};
323323
#else
324-
return Version{3, 2};
324+
return Version{3, 3};
325325
#endif
326326
case 4:
327327
static_assert(SWIFT_VERSION_MAJOR == 4,
328328
"getCurrentLanguageVersion is no longer correct here");
329329
return Version::getCurrentLanguageVersion();
330+
case 5:
331+
return Version{5, 0};
330332
default:
331333
return None;
332334
}

lib/ClangImporter/ImportName.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ importer::nameVersionFromOptions(const LangOptions &langOpts) {
6565
return ImportNameVersion::Swift2;
6666
case 3:
6767
return ImportNameVersion::Swift3;
68+
// Fixme: Figure out the importing story for 5 instead of falling back to 4.
6869
case 4:
70+
case 5:
6971
return ImportNameVersion::Swift4;
7072
}
7173
}

test/Driver/swift-version-default.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ htn
2424
#endif
2525

2626
#if swift(>=4.1)
27-
aoeu
27+
aoeu // expected-error {{use of unresolved identifier}}
2828
#else
29-
htn // expected-error {{use of unresolved identifier}}
29+
htn
3030
#endif
3131

3232
#if swift(>=5)

test/Driver/swift-version.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@
77
// RUN: not %target-swiftc_driver -swift-version 3.0 %s 2>&1 | %FileCheck --check-prefix FIXIT_3 %s
88
// RUN: not %target-swiftc_driver -swift-version 3.3 %s 2>&1 | %FileCheck --check-prefix FIXIT_3 %s
99
// 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
1011

1112
// RUN: not %target-swiftc_driver -swift-version 3 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_3 %s
1213
// RUN: not %target-swiftc_driver -swift-version 4 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_4 %s
14+
// RUN: not %target-swiftc_driver -swift-version 5 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_5 %s
1315

1416
// BAD: invalid value
15-
// BAD: note: valid arguments to '-swift-version' are '3', '4'
17+
// BAD: note: valid arguments to '-swift-version' are '3', '4', '5'
1618

1719
// FIXIT_3: use major version, as in '-swift-version 3'
1820
// FIXIT_4: use major version, as in '-swift-version 4'
21+
// FIXIT_5: use major version, as in '-swift-version 5'
1922

2023

2124
#if swift(>=3)
2225
asdf
2326
// ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
2427
// ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}}
28+
// ERROR_5: [[@LINE-3]]:1: error: {{use of unresolved identifier}}
2529
#else
2630
jkl
2731
#endif
@@ -30,26 +34,31 @@ jkl
3034
asdf
3135
// ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
3236
// ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}}
37+
// ERROR_5: [[@LINE-3]]:1: error: {{use of unresolved identifier}}
3338
#else
3439
jkl
3540
#endif
3641

3742
#if swift(>=4)
38-
asdf // ERROR_4: [[@LINE]]:1: error: {{use of unresolved identifier}}
43+
asdf
44+
// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
45+
// ERROR_5: [[@LINE-2]]:1: error: {{use of unresolved identifier}}
3946
#else
4047
jkl // ERROR_3: [[@LINE]]:1: error: {{use of unresolved identifier}}
4148
#endif
4249

4350
#if swift(>=4.1)
4451
asdf
52+
// ERROR_4: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
53+
// ERROR_5: [[@LINE-2]]:1: error: {{use of unresolved identifier}}
4554
#else
4655
jkl
4756
// ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
48-
// ERROR_4: [[@LINE-2]]:1: error: {{use of unresolved identifier}}
4957
#endif
5058

5159
#if swift(>=5)
5260
asdf
61+
// ERROR_5: [[@LINE-1]]:1: error: {{use of unresolved identifier}}
5362
#else
5463
jkl
5564
// ERROR_3: [[@LINE-1]]:1: error: {{use of unresolved identifier}}

test/Parse/ConditionalCompilation/language_version_explicit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#endif
2323

2424
#if swift(>=4.0.1)
25+
let z = 1
26+
#else
2527
// This shouldn't emit any diagnostics.
2628
asdf asdf asdf asdf
27-
#else
28-
let z = 1
2929
#endif
3030

test/Serialization/Recovery/crash-recovery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Sub: Base {
1414

1515
// CHECK-CRASH: error: fatal error encountered while reading from module 'Lib'; please file a bug report with your project and the crash log
1616
// CHECK-CRASH-3-NOT: note
17-
// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.2
17+
// CHECK-CRASH-4: note: compiling as Swift 4.1, with 'Lib' built as Swift 3.3
1818
// CHECK-CRASH-LABEL: *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
1919
// CHECK-CRASH: could not find 'disappearingMethod()' in parent class
2020
// CHECK-CRASH: While loading members for 'Sub' in module 'Lib'

test/Serialization/Recovery/types-4-to-3.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import Lib
1616
func requiresConformance(_: B_RequiresConformance<B_ConformsToProto>) {}
1717
func requiresConformance(_: B_RequiresConformance<C_RelyOnConformanceImpl.Assoc>) {}
1818

19-
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 4.0) because it has overridable members that could not be loaded in Swift 3.2}}
20-
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 4.0) because it has requirements that could not be loaded in Swift 3.2}}
19+
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 4.1) because it has overridable members that could not be loaded in Swift 3.3}}
20+
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 4.1) because it has requirements that could not be loaded in Swift 3.3}}
2121

2222
#else // TEST
2323

0 commit comments

Comments
 (0)