Skip to content

Commit 7d7ead6

Browse files
committed
AST: Introduce the AllowRuntimeSymbolDeclarations experimental feature.
This feature only exists as a mechanism to suppress the warning introduced in #75378. The RegexParser module, which is effectively part of the standard library, declares a Swift runtime symbol and as a result every build of the compiler and stdlib produces warnings which there are no plans to address. Warnings that are not going to be addressed need some way of being suppressed, and an experimental features seems like a reasonable mechanism for this one.
1 parent 97b249b commit 7d7ead6

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ EXPERIMENTAL_FEATURE(CompileTimeValues, true)
517517
/// Allow function body macros applied to closures.
518518
EXPERIMENTAL_FEATURE(ClosureBodyMacro, true)
519519

520+
/// Allow declarations of Swift runtime symbols using @_silgen_name.
521+
EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
522+
520523
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
521524
#undef EXPERIMENTAL_FEATURE
522525
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ UNINTERESTING_FEATURE(SafeInteropWrappers)
405405
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)
406406
UNINTERESTING_FEATURE(ImportNonPublicCxxMembers)
407407
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
408+
UNINTERESTING_FEATURE(AllowRuntimeSymbolDeclarations)
408409

409410
static bool usesFeatureSwiftSettings(const Decl *decl) {
410411
// We just need to guard `#SwiftSettings`.

lib/Sema/TypeCheckAttr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,12 @@ static bool canDeclareSymbolName(StringRef symbol, ModuleDecl *fromModule) {
24652465
return true;
24662466
}
24672467

2468+
// Allow reserved symbols to be declared if the AllowRuntimeSymbolDeclarations
2469+
// experimental feature is enabled.
2470+
auto &ctx = fromModule->getASTContext();
2471+
if (ctx.LangOpts.hasFeature(Feature::AllowRuntimeSymbolDeclarations))
2472+
return true;
2473+
24682474
// Swift runtime functions are a private contract between the compiler and
24692475
// runtime, and attempting to access them directly without going through
24702476
// builtins or proper language features breaks the compiler in various hard

stdlib/public/RegexParser/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ add_swift_target_library(swift_RegexParser ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
4747
# Workaround until `_RegexParser` is imported as implementation-only
4848
# by `_StringProcessing`.
4949
-Xfrontend -disable-implicit-string-processing-module-import
50+
-enable-experimental-feature AllowRuntimeSymbolDeclarations
5051
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
5152

5253
INSTALL_IN_COMPONENT stdlib

0 commit comments

Comments
 (0)