Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Enable Objective-C fixed enums feature for Swift #8

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/Lex/PPMacroExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,12 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
}


static bool hasModuleFeature(StringRef Feature, const LangOptions &LangOpts) {
return std::find(LangOpts.ModuleFeatures.begin(),
LangOpts.ModuleFeatures.end(),
Feature) != LangOpts.ModuleFeatures.end();
}

/// HasFeature - Return true if we recognize and implement the feature
/// specified by the identifier as a standard language feature.
static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
Expand Down Expand Up @@ -1093,7 +1099,8 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("objc_arc", LangOpts.ObjCAutoRefCount)
.Case("objc_arc_weak", LangOpts.ObjCWeak)
.Case("objc_default_synthesize_properties", LangOpts.ObjC2)
.Case("objc_fixed_enum", LangOpts.ObjC2)
.Case("objc_fixed_enum", LangOpts.ObjC2 ||
hasModuleFeature("swift", LangOpts))
.Case("objc_instancetype", LangOpts.ObjC2)
.Case("objc_kindof", LangOpts.ObjC2)
.Case("objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
Expand Down
8 changes: 7 additions & 1 deletion lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,12 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
T.getCloseLocation());
}

static bool hasModuleFeature(StringRef Feature, const LangOptions &LangOpts) {
return std::find(LangOpts.ModuleFeatures.begin(),
LangOpts.ModuleFeatures.end(),
Feature) != LangOpts.ModuleFeatures.end();
}

/// ParseEnumSpecifier
/// enum-specifier: [C99 6.7.2.2]
/// 'enum' identifier[opt] '{' enumerator-list '}'
Expand Down Expand Up @@ -3778,7 +3784,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,

bool AllowFixedUnderlyingType = AllowDeclaration &&
(getLangOpts().CPlusPlus11 || getLangOpts().MicrosoftExt ||
getLangOpts().ObjC2);
getLangOpts().ObjC2 || hasModuleFeature("swift", getLangOpts()));

CXXScopeSpec &SS = DS.getTypeSpecScope();
if (getLangOpts().CPlusPlus) {
Expand Down