@@ -5748,7 +5748,7 @@ Parser::parseDeclEnumCase(ParseDeclOptions Flags,
5748
5748
5749
5749
// Handle the likely case someone typed 'case X, case Y'.
5750
5750
if (Tok.is (tok::kw_case) && CommaLoc.isValid ()) {
5751
- diagnose (Tok , diag::expected_identifier_after_case_comma);
5751
+ diagnose (CommaLoc , diag::expected_identifier_after_case_comma);
5752
5752
Status.setIsParseError ();
5753
5753
return Status;
5754
5754
}
@@ -5782,16 +5782,16 @@ Parser::parseDeclEnumCase(ParseDeclOptions Flags,
5782
5782
return Status;
5783
5783
}
5784
5784
}
5785
- if (CommaLoc.isValid () && !NameIsKeyword) {
5786
- diagnose (CommaLoc, diag::expected_identifier_after_case_comma);
5787
- Status.setIsParseError ();
5788
- return Status;
5789
- } else if (NameIsKeyword) {
5785
+ if (NameIsKeyword) {
5790
5786
diagnose (TokLoc, diag::keyword_cant_be_identifier, TokText);
5791
5787
diagnose (TokLoc, diag::backticks_to_escape)
5792
5788
.fixItReplace (TokLoc, " `" + TokText.str () + " `" );
5793
5789
if (!Tok.isAtStartOfLine ())
5794
5790
consumeToken ();
5791
+ } else if (CommaLoc.isValid ()) {
5792
+ diagnose (CommaLoc, diag::expected_identifier_after_case_comma);
5793
+ Status.setIsParseError ();
5794
+ return Status;
5795
5795
} else {
5796
5796
diagnose (CaseLoc, diag::expected_identifier_in_decl, " enum 'case'" );
5797
5797
}
0 commit comments