Files
swift-mirror/test/Parse/ConditionalCompilation/decl_parse_errors.swift
Becca Royal-Gordon 0466d5c0ca Handle diagnostic verifier locations concretely
This commit makes a number of adjustments to how the diagnostic verifier handles source buffers and source locations. Specifically:

• Files named by `-verify-additional-file` are read as late as possible so that if some other component of the compiler has already loaded the file, even in some exotic way (e.g. ClangImporter’s source buffer mirroring), it will use the same buffer.
• Expectation source locations now ignore virtual files and other trickery; they are based on the source buffer and physical location in the file.

Hopefully this will make `-verify-additional-file` work better on Windows. As an unintended side effect, it also changes how expectations work in tests that use `#sourceLocation()`.
2025-02-11 12:05:17 -08:00

41 lines
1002 B
Swift

// RUN: %target-typecheck-verify-swift
public
#if FOO // expected-error {{expected declaration}}
var val1: Int = 0
#else
var val1: UInt = 1
#endif
struct S2 { // expected-note {{in declaration of 'S2'}}
@available(*, deprecated)
#if FOO // expected-error {{expected declaration}}
func fn1() {}
#endif
}
// expected-error@+2 {{expected declaration}}
private
#sourceLocation(file: "test.swift", line: 1)
var val2: Int = 0
#sourceLocation()
// expected-error@+3 {{expected declaration}}
// expected-error@+2 {{#line directive was renamed to #sourceLocation}}
lazy
#line 12 "test.swift"
var val3: Int = 0;
#line // expected-error {{#line directive was renamed to #sourceLocation}}
class C { // expected-note {{to match this opening '{'}}
#if os(iOS)
func foo() {}
} // expected-error{{unexpected '}' in conditional compilation block}}
#else
func bar() {}
func baz() {}
} // expected-error{{unexpected '}' in conditional compilation block}}
#endif
// expected-error@+1{{expected '}' in class}}