Skip to content

Commit 1bfe193

Browse files
committed
Frontend: Warn if adoption mode is requested but not supported
1 parent 7d74229 commit 1bfe193

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ GROUPED_WARNING(cannot_disable_feature_with_mode, StrictLanguageFeatures, none,
5959
"'%0' argument '%1' cannot specify a mode",
6060
(StringRef, StringRef))
6161

62+
GROUPED_WARNING(feature_does_not_support_adoption_mode, StrictLanguageFeatures,
63+
none,
64+
"feature '%0' does not support adoption mode",
65+
(StringRef))
66+
6267
ERROR(error_unknown_library_level, none,
6368
"unknown library level '%0', "
6469
"expected one of 'api', 'spi', 'ipi', or 'other'", (StringRef))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,13 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
831831
/*didYouMean=*/validModeName);
832832
continue;
833833
}
834+
835+
if (!isFeatureAdoptable(*feature)) {
836+
Diags.diagnose(SourceLoc(),
837+
diag::feature_does_not_support_adoption_mode,
838+
featureName);
839+
continue;
840+
}
834841
} else {
835842
// `-disable-*-feature` flags do not support a mode specifier.
836843
Diags.diagnose(SourceLoc(), diag::cannot_disable_feature_with_mode,

test/Frontend/strict_features_adoption_mode.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
// RUN: %target-swift-frontend -parse -swift-version 5 \
55
// RUN: -enable-upcoming-feature DynamicActorIsolation:invalid1 \
66
// RUN: -enable-upcoming-feature DynamicActorIsolation:invalid2 \
7+
// RUN: -enable-upcoming-feature DynamicActorIsolation:adoption \
8+
// RUN: -enable-upcoming-feature DynamicActorIsolation:adoption \
79
// RUN: -enable-experimental-feature DynamicActorIsolation:invalid3 \
810
// RUN: -enable-experimental-feature DynamicActorIsolation:invalid4 \
11+
// RUN: -enable-experimental-feature DynamicActorIsolation:adoption \
12+
// RUN: -enable-experimental-feature DynamicActorIsolation:adoption \
913
// RUN: -disable-upcoming-feature DynamicActorIsolation:invalid5 \
1014
// RUN: -disable-upcoming-feature DynamicActorIsolation:invalid6 \
1115
// RUN: -disable-upcoming-feature DynamicActorIsolation:adoption \
@@ -36,8 +40,12 @@
3640
// CHECK-SWIFT-5-NEXT: warning: '-disable-upcoming-feature' argument 'DynamicActorIsolation:adoption' cannot specify a mode{{$}}
3741
// CHECK-SWIFT-5-NEXT: warning: '-disable-upcoming-feature' argument 'DynamicActorIsolation:invalid6' cannot specify a mode{{$}}
3842
// CHECK-SWIFT-5-NEXT: warning: '-disable-upcoming-feature' argument 'DynamicActorIsolation:invalid5' cannot specify a mode{{$}}
43+
// CHECK-SWIFT-5-NEXT: warning: feature 'DynamicActorIsolation' does not support adoption mode{{$}}
44+
// CHECK-SWIFT-5-NEXT: warning: feature 'DynamicActorIsolation' does not support adoption mode{{$}}
3945
// CHECK-SWIFT-5-NEXT: warning: 'invalid4' is not a recognized mode for feature 'DynamicActorIsolation'; did you mean 'adoption'?{{$}}
4046
// CHECK-SWIFT-5-NEXT: warning: 'invalid3' is not a recognized mode for feature 'DynamicActorIsolation'; did you mean 'adoption'?{{$}}
47+
// CHECK-SWIFT-5-NEXT: warning: feature 'DynamicActorIsolation' does not support adoption mode{{$}}
48+
// CHECK-SWIFT-5-NEXT: warning: feature 'DynamicActorIsolation' does not support adoption mode{{$}}
4149
// CHECK-SWIFT-5-NEXT: warning: 'invalid2' is not a recognized mode for feature 'DynamicActorIsolation'; did you mean 'adoption'?{{$}}
4250
// CHECK-SWIFT-5-NEXT: warning: 'invalid1' is not a recognized mode for feature 'DynamicActorIsolation'; did you mean 'adoption'?{{$}}
4351
// CHECK-SWIFT-5-NOT: warning:

0 commit comments

Comments
 (0)