forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Parse] Unify recovery for invalid tokens following a
#if
body
Previously we would only diagnose and recover for invalid tokens following a `#if` body for the decl and postfix expression case. Sink this logic into `parseIfConfigRaw`, ensuring that we do this for all `#if` cases. This requires propagating the context we're parsing in to customize the diagnostic.
- Loading branch information
1 parent
cd9d202
commit a85ca13
Showing
7 changed files
with
84 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/Parse/ConditionalCompilation/pound-if-inside-function-5.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// Make sure we can recover by ignoring the '}' in the #if. | ||
struct S { | ||
func foo() { | ||
#if true | ||
} // expected-error {{unexpected '}' in conditional compilation block}} | ||
#endif | ||
} | ||
func bar() { | ||
#if false | ||
} // expected-error {{unexpected '}' in conditional compilation block}} | ||
#endif | ||
} | ||
func baz() {} | ||
} |