[SE-0458] Enable unsafe expressions / attributes / for..in effects by default

With the acceptance of SE-0458, allow the use of unsafe expressions, the
@safe and @unsafe attributes, and the `unsafe` effect on the for..in loop
in all Swift code.

Introduce the `-strict-memory-safety` flag detailed in the proposal to
enable strict memory safety checking. This enables a new class of
feature, an optional feature (that is *not* upcoming or experimental),
and which can be detected via `hasFeature(StrictMemorySafety)`.
This commit is contained in:
Doug Gregor
2025-02-26 12:30:07 -08:00
parent 71e23ac757
commit b7b5a2a19d
37 changed files with 112 additions and 119 deletions

View File

@@ -878,6 +878,9 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
Opts.enableFeature(Feature::LayoutPrespecialization);
if (Args.hasArg(OPT_strict_memory_safety))
Opts.enableFeature(Feature::StrictMemorySafety);
return HadError;
}
@@ -3909,7 +3912,7 @@ bool CompilerInvocation::parseArgs(
}
}
if (LangOpts.hasFeature(Feature::WarnUnsafe)) {
if (LangOpts.hasFeature(Feature::StrictMemorySafety)) {
if (SILOpts.RemoveRuntimeAsserts ||
SILOpts.AssertConfig == SILOptions::Unchecked) {
Diags.diagnose(SourceLoc(),