Skip to content

Commit 73a2041

Browse files
committed
Only define the various Macros features when the compiler supports them
We were enabling the `$Macros` feature unconditionally, even when the compiler itself doesn't support macros (because it's missing swift-syntax). Change this to only enable the feature when the compiler supports it.
1 parent 49277f7 commit 73a2041

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated
9494
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync", true)
9595
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)", true)
9696
LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors", true)
97-
LANGUAGE_FEATURE(Macros, 0, "Macros", true)
97+
LANGUAGE_FEATURE(Macros, 0, "Macros", hasSwiftSwiftParser)
9898
SUPPRESSIBLE_LANGUAGE_FEATURE(
9999
FreestandingExpressionMacros, 382, "Expression macros",
100-
true)
101-
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros", true)
100+
hasSwiftSwiftParser)
101+
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros", hasSwiftSwiftParser)
102102
LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types", true)
103103

104104
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)

lib/Parse/ParseIfConfig.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ class EvaluateIfConfigCondition :
555555

556556
// Check whether this is any one of the known compiler features.
557557
const auto &langOpts = Ctx.LangOpts;
558+
#if SWIFT_SWIFT_PARSER
559+
const bool hasSwiftSwiftParser = true;
560+
#else
561+
const bool hasSwiftSwiftParser = false;
562+
#endif
558563
bool isKnownFeature = llvm::StringSwitch<bool>(Name)
559564
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
560565
.Case("$" #FeatureName, Option)

0 commit comments

Comments
 (0)