diff options
author | Russ Cox <rsc@golang.org> | 2013-02-01 23:10:02 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2013-02-01 23:10:02 -0500 |
commit | 1688d2d3509547436f2e6900efee3b23d18773d8 (patch) | |
tree | 3ca83bae682c1177f1d4d9cae6370210cf354cef /test/run.go | |
parent | d8d17d345bee871b8c550e4d51164b86fcd53a3d (diff) | |
download | go-1688d2d3509547436f2e6900efee3b23d18773d8.tar.gz |
cmd/gc: reject non-Go constants
Expressions involving nil, even if they can be evaluated
at compile time, do not count as Go constants and cannot
be used in const initializers.
Fixes issue 4673.
Fixes issue 4680.
R=ken2
CC=golang-dev
https://codereview.appspot.com/7278043
Diffstat (limited to 'test/run.go')
-rw-r--r-- | test/run.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/test/run.go b/test/run.go index bc545df10..36c8b7ad7 100644 --- a/test/run.go +++ b/test/run.go @@ -683,6 +683,7 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { continue } matched := false + n := len(out) for _, errmsg := range errmsgs { if we.re.MatchString(errmsg) { matched = true @@ -691,7 +692,7 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) { } } if !matched { - errs = append(errs, fmt.Errorf("%s:%d: no match for %q in%s", we.file, we.lineNum, we.reStr, strings.Join(out, "\n"))) + errs = append(errs, fmt.Errorf("%s:%d: no match for %#q in:\n\t%s", we.file, we.lineNum, we.reStr, strings.Join(out[n:], "\n\t"))) continue } } @@ -758,7 +759,7 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { all := m[1] mm := errQuotesRx.FindAllStringSubmatch(all, -1) if mm == nil { - log.Fatalf("invalid errchk line in %s: %s", t.goFileName(), line) + log.Fatalf("%s:%d: invalid errchk line: %s", t.goFileName(), lineNum, line) } for _, m := range mm { rx := lineRx.ReplaceAllStringFunc(m[1], func(m string) string { @@ -772,10 +773,14 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { } return fmt.Sprintf("%s:%d", short, n) }) - filterPattern := fmt.Sprintf(`^(\w+/)?%s:%d[:[]`, short, lineNum) + re, err := regexp.Compile(rx) + if err != nil { + log.Fatalf("%s:%d: invalid regexp in ERROR line: %v", t.goFileName(), lineNum, err) + } + filterPattern := fmt.Sprintf(`^(\w+/)?%s:%d[:[]`, regexp.QuoteMeta(short), lineNum) errs = append(errs, wantedError{ reStr: rx, - re: regexp.MustCompile(rx), + re: re, filterRe: regexp.MustCompile(filterPattern), lineNum: lineNum, file: short, |