Skip to content

Commit 0ce9104

Browse files
authored
Merge pull request swiftlang#75950 from tshortli/asserts-swift-7
Basic: Add support for `-swift-version 7` to asserts mode compilers
2 parents 5490886 + 47454e3 commit 0ce9104

File tree

6 files changed

+78
-50
lines changed

6 files changed

+78
-50
lines changed

lib/Basic/Version.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ std::optional<Version> Version::getEffectiveLanguageVersion() const {
181181
static_assert(SWIFT_VERSION_MAJOR == 6,
182182
"getCurrentLanguageVersion is no longer correct here");
183183
return Version::getCurrentLanguageVersion();
184+
case 7:
185+
// Allow version '7' in asserts compilers *only* so that we can start
186+
// testing changes planned for after Swift 6. Note that it's still not
187+
// listed in `Version::getValidEffectiveVersions()`.
188+
// FIXME: When Swift 7 becomes real, remove 'REQUIRES: swift7' from tests
189+
// using '-swift-version 7'.
190+
#ifdef NDEBUG
191+
LLVM_FALLTHROUGH;
192+
#else
193+
return Version{7};
194+
#endif
184195
default:
185196
return std::nullopt;
186197
}

test/Driver/swift-version-6.swift

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: not %target-swiftc_driver -swift-version 7 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_7 %s
2+
// REQUIRES: swift7
3+
4+
#if swift(>=3)
5+
asdf
6+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
7+
#else
8+
jkl
9+
#endif
10+
11+
#if swift(>=3.1)
12+
asdf
13+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
14+
#else
15+
jkl
16+
#endif
17+
18+
#if swift(>=4)
19+
asdf
20+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
21+
#else
22+
jkl
23+
#endif
24+
25+
#if swift(>=4.1)
26+
asdf
27+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
28+
#else
29+
jkl
30+
#endif
31+
32+
#if swift(>=6)
33+
asdf
34+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
35+
#else
36+
jkl
37+
#endif
38+
39+
#if swift(>=7)
40+
asdf
41+
// ERROR_7: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
42+
#else
43+
jkl
44+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: not %target-swiftc_driver -swift-version 7 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_7 %s
2+
// REQUIRES: no_asserts
3+
4+
// ERROR_7: <unknown>:0: error: invalid value '7' in '-swift-version 7'
5+
// ERROR_7: <unknown>:0: note: valid arguments to '-swift-version' are '4', '4.2', '5', '6'

test/Driver/swift-version.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
// RUN: not %target-swiftc_driver -swift-version 1 %s 2>&1 | %FileCheck --check-prefix BAD %s
33
// RUN: not %target-swiftc_driver -swift-version 2 %s 2>&1 | %FileCheck --check-prefix BAD %s
44
// RUN: not %target-swiftc_driver -swift-version 2.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
5-
// RUN: not %target-swiftc_driver -swift-version 7 %s 2>&1 | %FileCheck --check-prefix BAD %s
6-
// RUN: not %target-swiftc_driver -swift-version 7.2 %s 2>&1 | %FileCheck --check-prefix BAD %s
75
// RUN: not %target-swiftc_driver -swift-version 3.0 %s 2>&1 | %FileCheck --check-prefix BAD %s
86
// RUN: not %target-swiftc_driver -swift-version 3.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
97
// RUN: not %target-swiftc_driver -swift-version 4.3 %s 2>&1 | %FileCheck --check-prefix BAD %s
108
// RUN: not %target-swiftc_driver -swift-version 5.1 %s 2>&1 | %FileCheck --check-prefix BAD %s
119

1210
// RUN: not %target-swiftc_driver -swift-version 4 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_4 %s
1311
// RUN: not %target-swiftc_driver -swift-version 5 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_5 %s
12+
// RUN: not %target-swiftc_driver -swift-version 6 -typecheck %s 2>&1 | %FileCheck --check-prefix ERROR_6 %s
1413

1514
// BAD: invalid value
16-
// BAD: note: valid arguments to '-swift-version' are '4', '4.2', '5'
15+
// BAD: note: valid arguments to '-swift-version' are '4', '4.2', '5', '6'
1716

1817
#if swift(>=3)
1918
asdf
2019
// ERROR_4: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
2120
// ERROR_5: [[@LINE-2]]:1: error: {{cannot find 'asdf' in scope}}
21+
// ERROR_6: [[@LINE-3]]:1: error: {{cannot find 'asdf' in scope}}
2222
#else
2323
jkl
2424
#endif
@@ -27,6 +27,7 @@ jkl
2727
asdf
2828
// ERROR_4: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
2929
// ERROR_5: [[@LINE-2]]:1: error: {{cannot find 'asdf' in scope}}
30+
// ERROR_6: [[@LINE-3]]:1: error: {{cannot find 'asdf' in scope}}
3031
#else
3132
jkl
3233
#endif
@@ -35,6 +36,7 @@ jkl
3536
asdf
3637
// ERROR_4: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
3738
// ERROR_5: [[@LINE-2]]:1: error: {{cannot find 'asdf' in scope}}
39+
// ERROR_6: [[@LINE-3]]:1: error: {{cannot find 'asdf' in scope}}
3840
#else
3941
jkl
4042
#endif
@@ -43,14 +45,25 @@ jkl
4345
asdf
4446
// ERROR_4: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
4547
// ERROR_5: [[@LINE-2]]:1: error: {{cannot find 'asdf' in scope}}
48+
// ERROR_6: [[@LINE-3]]:1: error: {{cannot find 'asdf' in scope}}
4649
#else
4750
jkl
4851
#endif
4952

5053
#if swift(>=5)
5154
asdf
5255
// ERROR_5: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
56+
// ERROR_6: [[@LINE-2]]:1: error: {{cannot find 'asdf' in scope}}
5357
#else
5458
jkl
5559
// ERROR_4: [[@LINE-1]]:1: error: {{cannot find 'jkl' in scope}}
5660
#endif
61+
62+
#if swift(>=6)
63+
asdf
64+
// ERROR_6: [[@LINE-1]]:1: error: {{cannot find 'asdf' in scope}}
65+
#else
66+
jkl
67+
// ERROR_5: [[@LINE-1]]:1: error: {{cannot find 'jkl' in scope}}
68+
// ERROR_4: [[@LINE-2]]:1: error: {{cannot find 'jkl' in scope}}
69+
#endif

test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ if '@SWIFT_STDLIB_ENABLE_LTO@'.lower() in ['full', 'thin']:
9696

9797
if "@LLVM_ENABLE_ASSERTIONS@" == "TRUE":
9898
config.available_features.add('asserts')
99+
# Tests that require -swift-version 7 can only run with asserts compilers
100+
config.available_features.add('swift7')
99101
else:
100102
config.available_features.add('no_asserts')
101103

0 commit comments

Comments
 (0)