@@ -6337,8 +6337,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
6337
6337
DescriptiveKind = DescriptiveDeclKind::StaticProperty;
6338
6338
break ;
6339
6339
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 ;
6342
6342
}
6343
6343
6344
6344
diagnose (Tok.getLoc (), diag::expected_keyword_in_decl, " var" ,
@@ -6366,8 +6366,7 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
6366
6366
DescriptiveKind = DescriptiveDeclKind::StaticMethod;
6367
6367
break ;
6368
6368
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;
6371
6370
}
6372
6371
}
6373
6372
@@ -9229,6 +9228,20 @@ ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
9229
9228
return DCC.fixupParserResult (Status, ED);
9230
9229
}
9231
9230
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
+
9232
9245
// / Parse a 'case' of an enum.
9233
9246
// /
9234
9247
// / \verbatim
@@ -9346,8 +9359,7 @@ Parser::parseDeclEnumCase(ParseDeclOptions Flags,
9346
9359
}
9347
9360
// The raw value must be syntactically a simple literal.
9348
9361
LiteralRawValueExpr = dyn_cast<LiteralExpr>(RawValueExpr.getPtrOrNull ());
9349
- if (!LiteralRawValueExpr
9350
- || isa<InterpolatedStringLiteralExpr>(LiteralRawValueExpr)) {
9362
+ if (!isValidEnumRawValueLiteral (LiteralRawValueExpr)) {
9351
9363
diagnose (RawValueExpr.getPtrOrNull ()->getLoc (),
9352
9364
diag::nonliteral_enum_case_raw_value);
9353
9365
LiteralRawValueExpr = nullptr ;
0 commit comments