mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Frontend: Implement optional parsing diagnostics for enabled language features.
Parsing for `-enable-upcoming-feature` and `-enable-experimental-feature` is lenient by default because some projects need to be compatible with multiple language versions and compiler toolchains simultaneously, and strict diagnostics would be a nuisance. On the other hand, though, it would be useful to get feedback from the compiler when you attempt to enable a feature that doesn't exist. This change splits the difference by introducing new diagnostics for potential feature enablement misconfigurations but leaves those diagnostics ignored by default. Projects that wish to use them can specify `-Wwarning StrictLanguageFeatures`.
This commit is contained in:
@@ -26,6 +26,7 @@ GROUP(DeprecatedDeclaration, "DeprecatedDeclaration.md")
|
||||
GROUP(Unsafe, "Unsafe.md")
|
||||
GROUP(UnknownWarningGroup, "UnknownWarningGroup.md")
|
||||
GROUP(PreconcurrencyImport, "PreconcurrencyImport.md")
|
||||
GROUP(StrictLanguageFeatures, "StrictLanguageFeatures.md")
|
||||
|
||||
#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
|
||||
#include "swift/AST/DefineDiagnosticGroupsMacros.h"
|
||||
|
||||
@@ -37,8 +37,18 @@ ERROR(error_unsupported_target_arch, none,
|
||||
"unsupported target architecture: '%0'", (StringRef))
|
||||
|
||||
WARNING(warning_upcoming_feature_on_by_default, none,
|
||||
"upcoming feature '%0' is already enabled as of Swift version %1",
|
||||
(StringRef, unsigned))
|
||||
"upcoming feature '%0' is already enabled as of Swift version %1",
|
||||
(StringRef, unsigned))
|
||||
|
||||
GROUPED_WARNING(unrecognized_feature, StrictLanguageFeatures, DefaultIgnore,
|
||||
"'%0' is not a recognized "
|
||||
"%select{experimental|upcoming}1 feature",
|
||||
(StringRef, bool))
|
||||
|
||||
GROUPED_WARNING(feature_not_experimental, StrictLanguageFeatures, DefaultIgnore,
|
||||
"'%0' is not an experimental feature, "
|
||||
"use -%select{disable|enable}1-upcoming-feature instead",
|
||||
(StringRef, bool))
|
||||
|
||||
ERROR(error_unknown_library_level, none,
|
||||
"unknown library level '%0', "
|
||||
|
||||
Reference in New Issue
Block a user