mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SwiftCompiler/Regex] Use bridged DiagnosticEngine for error reporting
This fixes: * An issue where the diagnostic messages were leaked * Diagnose at correct position inside the regex literal To do this: * Introduce 'Parse' SwiftCompiler module that is a bridging layer between '_CompilerRegexParser' and C++ libParse * Move libswiftParseRegexLiteral and libswiftLexRegexLiteral to 'Parse' Also this change makes 'SwiftCompilerSources/Package.swift' be configured by CMake so it can actually be built with 'swift-build'. rdar://92187284
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
|
||||
// REQUIRES: swift_in_compiler
|
||||
|
||||
_ = /(/ // expected-error {{expected ')'}}
|
||||
_ = #/(/# // expected-error {{expected ')'}}
|
||||
_ = /(/ // expected-error@:7 {{expected ')'}}
|
||||
_ = #/(/# // expected-error@:8 {{expected ')'}}
|
||||
|
||||
// FIXME: Should be 'group openings'
|
||||
_ = /)/ // expected-error {{closing ')' does not balance any groups openings}}
|
||||
_ = #/)/# // expected-error {{closing ')' does not balance any groups openings}}
|
||||
_ = /)/ // expected-error@:6 {{closing ')' does not balance any groups openings}}
|
||||
_ = #/)/# // expected-error@:7 {{closing ')' does not balance any groups openings}}
|
||||
|
||||
_ = #/\\/''/ // expected-error {{unterminated regex literal}}
|
||||
_ = #/\| // expected-error {{unterminated regex literal}}
|
||||
_ = #// // expected-error {{unterminated regex literal}}
|
||||
_ = #/\\/''/ // expected-error@:5 {{unterminated regex literal}}
|
||||
_ = #/\| // expected-error@:5 {{unterminated regex literal}}
|
||||
_ = #// // expected-error@:5 {{unterminated regex literal}}
|
||||
|
||||
_ = #/xy // expected-error {{unterminated regex literal}}
|
||||
_ = #/xy // expected-error@:5 {{unterminated regex literal}}
|
||||
|
||||
_ = #/(?/# // expected-error {{expected group specifier}}
|
||||
_ = #/(?'/# // expected-error {{expected group name}}
|
||||
_ = #/(?'abc/# // expected-error {{expected '''}}
|
||||
_ = #/(?'abc /# // expected-error {{expected '''}}
|
||||
_ = #/(?/# // expected-error@:7 {{expected group specifier}}
|
||||
_ = #/(?'/# // expected-error@:10 {{expected group name}}
|
||||
_ = #/(?'abc/# // expected-error@:13 {{expected '''}}
|
||||
_ = #/(?'abc /# // expected-error@:13 {{expected '''}}
|
||||
|
||||
do {
|
||||
_ = #/(?'a
|
||||
// expected-error@-1 {{unterminated regex literal}}
|
||||
// expected-error@-2 {{cannot parse regular expression: expected '''}}
|
||||
// expected-error@-1:7 {{unterminated regex literal}}
|
||||
// expected-error@-2:13 {{cannot parse regular expression: expected '''}}
|
||||
}
|
||||
|
||||
_ = #/\(?'abc/#
|
||||
@@ -30,21 +30,21 @@ _ = #/\(?'abc/#
|
||||
do {
|
||||
_ = /\
|
||||
/
|
||||
// expected-error@-2 {{unterminated regex literal}}
|
||||
// expected-error@-3 {{expected escape sequence}}
|
||||
} // expected-error {{expected expression after operator}}
|
||||
// expected-error@-2:7 {{unterminated regex literal}}
|
||||
// expected-error@-3:9 {{expected escape sequence}}
|
||||
} // expected-error@:1 {{expected expression after operator}}
|
||||
|
||||
do {
|
||||
_ = #/\
|
||||
/#
|
||||
// expected-error@-2 {{unterminated regex literal}}
|
||||
// expected-error@-3 {{expected escape sequence}}
|
||||
// expected-error@-3 {{unterminated regex literal}}
|
||||
// expected-warning@-4 {{regular expression literal is unused}}
|
||||
// expected-error@-2:7 {{unterminated regex literal}}
|
||||
// expected-error@-3:10 {{expected escape sequence}}
|
||||
// expected-error@-3:3 {{unterminated regex literal}}
|
||||
// expected-warning@-4:3 {{regular expression literal is unused}}
|
||||
}
|
||||
|
||||
func foo<T>(_ x: T, _ y: T) {}
|
||||
foo(#/(?/#, #/abc/#) // expected-error {{expected group specifier}}
|
||||
foo(#/(?C/#, #/abc/#) // expected-error {{expected ')'}}
|
||||
foo(#/(?/#, #/abc/#) // expected-error@:7 {{expected group specifier}}
|
||||
foo(#/(?C/#, #/abc/#) // expected-error@:10 {{expected ')'}}
|
||||
|
||||
foo(#/(?'/#, #/abc/#) // expected-error {{expected group name}}
|
||||
foo(#/(?'/#, #/abc/#) // expected-error@:10 {{expected group name}}
|
||||
|
||||
Reference in New Issue
Block a user