mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user