diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-12-09 15:43:44 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-12-09 15:46:19 -0800 |
commit | 0c2200e4198df9294aba102519f662a907596623 (patch) | |
tree | 9415bca69cdc4185ab142fcca0e5af07a1371dba /gcc | |
parent | 7d9767cb8eea0f21c5b23b0183c53840e0433397 (diff) | |
download | gcc-0c2200e4198df9294aba102519f662a907596623.zip gcc-0c2200e4198df9294aba102519f662a907596623.tar.gz gcc-0c2200e4198df9294aba102519f662a907596623.tar.bz2 |
go-test.exp: rewrite errchk regexp quoting
* go.test/go-test.exp (errchk): Rewrite regexp quoting to use
curly braces, making it much simpler.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/go.test/go-test.exp | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/gcc/testsuite/go.test/go-test.exp b/gcc/testsuite/go.test/go-test.exp index d129e1c..d11a2c2 100644 --- a/gcc/testsuite/go.test/go-test.exp +++ b/gcc/testsuite/go.test/go-test.exp @@ -101,50 +101,32 @@ proc errchk { test opts } { set changed "" while { $changed != $copy_line } { set changed $copy_line - regsub "\(// \[^\"\]*\"\[^\"\]*\)\" \"" $copy_line "\\1|" out_line + regsub {(// [^"]*"[^"]*)" "} $copy_line {\1|} out_line set copy_line $out_line } - regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\" *\(\\*/\)?$" $copy_line "// \{ dg-error \"\\2\" \}\\3" out_line - if [string match "*dg-error*\\\[*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\\\\\\\[" $out_line "\\\\\\\\\\\[" out_line - } - if [string match "*dg-error*\\\]*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\\\\\\\]" $out_line "\\\\\\\\\\\]" out_line - } - if [string match "*dg-error*.\**" $out_line] { - # I worked out the right number of backslashes by - # experimentation, not analysis. - regsub -all "\\.\\*" $out_line "\\\\\[ -~\\\\\]*" out_line - } - if [string match "*dg-error*\\\[?\\\]*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -all "\\\[\(.\)\\\]" $out_line "\\\\\[\\1\\\\\]" out_line - } - if [string match "*dg-error*\{*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\(\[^\\\\]\)\{" $out_line "\\1\\\\\[\\\{\\\\\]" out_line - } - if [string match "*dg-error*\}*\}" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\(\[^\\\\]\)\}\(.\)" $out_line "\\1\\\\\[\\\}\\\\\]\\2" out_line - } - if [string match "*dg-error*\\\[^\\\\\]\(*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\\\\\\\(" $out_line "\\\\\[\\\(\\\\\]" out_line - } - if [string match "*dg-error*\\\[^\\\\\]\)*\}" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index -all "\\\\\\\)\(.\)" $out_line "\\\\\[\\\)\\\\\]\\1" out_line - } - # Special case for bug332, in which the error message wants to - # match the file name, which is not what dg-error expects. - if [string match "*dg-error*bug332*" $out_line] { - set index [string first "dg-error" $out_line] - regsub -start $index "bug332" $out_line "undefined type" out_line + set index [string first // $copy_line] + set eindex [string first ERROR $copy_line] + if { $index >= 0 && $eindex > $index } { + # We're putting the regexp in curly braces, so replace any + # curly braces in the regexp with hex escapes. + regsub -start $index -all "\{" $copy_line {\x7b} copy_line + regsub -start $index -all "\}" $copy_line {\x7d} copy_line + + # Replace .* with [ -~]* because .* will eat newlines. + # We can't easily use (?n) because this regexp will appear + # in the middle of a large regexp. + regsub -all {\.\*} $copy_line {[ -~]*} copy_line } + + # Change + # // ERROR "string" + # to + # // { dg-error {string} } + # The latter is what go-dg-runtest expects. + # Retain an optional trailing */, for syntax/semi6.go. + regsub {// (GCCGO_)?ERROR "([^"]*)" *(\*/)?$} $copy_line "// \{ dg-error \{\\2\} \}\\3" out_line + puts $fdout $out_line } close $fdin |