Basic: Add support for -swift-version 7 to asserts mode compilers.

Begin accepting `-swift-version 7` in asserts compilers so that we can begin to
test source-breaking changes intended for the next language version mode, such
as diagnostics that need to be staged in without breaking existing code. There
are no announced plans yet for a language mode after Swift 6, so 7 serves as a
placeholder for some future language mode.

Tests that wish to use `-swift-version 7` currently must be marked with
`REQUIRES: swift7` or they will fail in no-asserts bots. The simplest pattern
is probably to duplicate part or all of the pre-Swift 7 test to check that will
behave as intended in Swift 7.
This commit is contained in:
Allan Shortlidge
2024-08-18 16:47:03 -07:00
parent 9315673c00
commit 47454e3f03
6 changed files with 78 additions and 50 deletions

View File

@@ -181,6 +181,17 @@ std::optional<Version> Version::getEffectiveLanguageVersion() const {
static_assert(SWIFT_VERSION_MAJOR == 6,
"getCurrentLanguageVersion is no longer correct here");
return Version::getCurrentLanguageVersion();
case 7:
// Allow version '7' in asserts compilers *only* so that we can start
// testing changes planned for after Swift 6. Note that it's still not
// listed in `Version::getValidEffectiveVersions()`.
// FIXME: When Swift 7 becomes real, remove 'REQUIRES: swift7' from tests
// using '-swift-version 7'.
#ifdef NDEBUG
LLVM_FALLTHROUGH;
#else
return Version{7};
#endif
default:
return std::nullopt;
}