Files
swift-mirror/test/Parse/ConditionalCompilation/pound-if-inside-function-5.swift
Hamish Knight a85ca1315b [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.
2024-06-19 21:39:40 +01:00

17 lines
348 B
Swift

// 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() {}
}