@@ -6337,8 +6337,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
63376337 DescriptiveKind = DescriptiveDeclKind::StaticProperty;
63386338 break ;
63396339 case StaticSpellingKind::KeywordClass:
6340- llvm_unreachable ( " kw_class is only parsed as a modifier if it's "
6341- " followed by a keyword " ) ;
6340+ DescriptiveKind = DescriptiveDeclKind::ClassProperty;
6341+ break ;
63426342 }
63436343
63446344 diagnose (Tok.getLoc (), diag::expected_keyword_in_decl, " var" ,
@@ -6366,8 +6366,7 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
63666366 DescriptiveKind = DescriptiveDeclKind::StaticMethod;
63676367 break ;
63686368 case StaticSpellingKind::KeywordClass:
6369- llvm_unreachable (" kw_class is only parsed as a modifier if it's "
6370- " followed by a keyword" );
6369+ DescriptiveKind = DescriptiveDeclKind::ClassMethod;
63716370 }
63726371 }
63736372
@@ -9229,6 +9228,20 @@ ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
92299228 return DCC.fixupParserResult (Status, ED);
92309229}
92319230
9231+ static bool isValidEnumRawValueLiteral (LiteralExpr *expr) {
9232+ if (expr == nullptr )
9233+ return false ;
9234+
9235+ if (!isa<IntegerLiteralExpr>(expr) &&
9236+ !isa<FloatLiteralExpr>(expr) &&
9237+ !isa<StringLiteralExpr>(expr) &&
9238+ !isa<BooleanLiteralExpr>(expr) &&
9239+ !isa<NilLiteralExpr>(expr))
9240+ return false ;
9241+
9242+ return true ;
9243+ }
9244+
92329245// / Parse a 'case' of an enum.
92339246// /
92349247// / \verbatim
@@ -9346,8 +9359,7 @@ Parser::parseDeclEnumCase(ParseDeclOptions Flags,
93469359 }
93479360 // The raw value must be syntactically a simple literal.
93489361 LiteralRawValueExpr = dyn_cast<LiteralExpr>(RawValueExpr.getPtrOrNull ());
9349- if (!LiteralRawValueExpr
9350- || isa<InterpolatedStringLiteralExpr>(LiteralRawValueExpr)) {
9362+ if (!isValidEnumRawValueLiteral (LiteralRawValueExpr)) {
93519363 diagnose (RawValueExpr.getPtrOrNull ()->getLoc (),
93529364 diag::nonliteral_enum_case_raw_value);
93539365 LiteralRawValueExpr = nullptr ;
0 commit comments