Merge pull request #25008 from owenv/improved_#else_if_diagnostic

[Parse] Improve diagnostic and add fixit to correct '#else if' to '#elseif'
This commit is contained in:
Rintaro Ishizaki
2019-05-24 09:38:12 -07:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -595,6 +595,12 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
Expr *Condition = nullptr;
bool isActive = false;
if (!Tok.isAtStartOfLine() && isElse && Tok.is(tok::kw_if)) {
diagnose(Tok, diag::unexpected_if_following_else_compilation_directive)
.fixItReplace(SourceRange(ClauseLoc, consumeToken()), "#elseif");
isElse = false;
}
// Parse the condition. Evaluate it to determine the active
// clause unless we're doing a parse-only pass.
if (isElse) {