mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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()`.
28 lines
1.5 KiB
Swift
28 lines
1.5 KiB
Swift
// RUN: rm -f %t.*
|
|
|
|
// Test swift executable
|
|
// RUN: %target-swift-frontend -typecheck -serialize-diagnostics-path %t.dia %s -verify
|
|
// RUN: c-index-test -read-diagnostics %t.dia > %t.deserialized_diagnostics.txt 2>&1
|
|
// RUN: %FileCheck --input-file=%t.deserialized_diagnostics.txt %s
|
|
|
|
var x = 1 x = 2 // expected-error {{consecutive statements on a line must be separated by ';'}} {{10-10=;}}
|
|
// CHECK: {{.*[/\\]}}serialized-diagnostics.swift:[[@LINE-1]]:10: error: consecutive statements on a line must be separated by ';' [] []
|
|
// CHECK-NEXT: Number FIXITs = 1
|
|
// CHECK-NEXT: FIXIT: ({{.*[/\\]}}serialized-diagnostics.swift:[[@LINE-3]]:10 - {{.*[/\\]}}serialized-diagnostics.swift:[[@LINE-3]]:10): ";"
|
|
|
|
var z : Int // expected-note 2 {{previously declared here}}
|
|
var z : Int // expected-error {{invalid redeclaration}}
|
|
// CHECK-NEXT: {{.*[/\\]}}serialized-diagnostics.swift:[[@LINE-1]]:5: error: invalid redeclaration of 'z' [] []
|
|
// CHECK-NEXT: Number FIXITs = 0
|
|
// CHECK-NEXT: +-{{.*[/\\]}}serialized-diagnostics.swift:[[@LINE-4]]:5: note: 'z' previously declared here [] []
|
|
// CHECK-NEXT: Number FIXITs = 0
|
|
|
|
#sourceLocation(file: "fake-file.swuft", line: 4)
|
|
var z : Int // expected-error {{invalid redeclaration of 'z'}}
|
|
// CHECK-NEXT: {{^}}fake-file.swuft:4:5: error: invalid redeclaration of 'z' [] []
|
|
// CHECK-NEXT: Number FIXITs = 0
|
|
// CHECK-NEXT: +-{{.*[/\\]}}serialized-diagnostics.swift:{{[0-9]+}}:5: note: 'z' previously declared here [] []
|
|
// CHECK-NEXT: Number FIXITs = 0
|
|
|
|
// CHECK-NEXT: Number of diagnostics: 3
|