aboutsummaryrefslogtreecommitdiff
path: root/test/shift1.go
AgeCommit message (Collapse)Author
2021-12-03test: re-enable a bunch of tests with types2Dan Scales
Enable a bunch of types2-related error tests to run successfully, so they no longer have to be disabled in run.go. - directive.go: split it into directive.go and directive2.go, since the possible errors are now split across the parser and noder2, so they can't all be reported in one file. - linkname2.go: similarly, split it into linkname2.go and linkname3.go for the same reason. - issue16428.go, issue17645.go, issue47201.dir/bo.go: handle slightly different wording by types2 - issue5609.go: handle slight different error (array length must be integer vs. array bound too large). - float_lit3.go: handle slightly different wording (overflows float vs cannot convert to float) I purposely didn't try to fix tests yet where there are extra or missing errors on different lines, since that is not easy to make work for both -G=3 and -G=0. In a later change, will flip to make the types2 version match correctly, vs. the -G=0 version. Change-Id: I6079ff258e3b90146335b9995764e3b1b56cda59 Reviewed-on: https://go-review.googlesource.com/c/go/+/368455 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-30test: recognize gofrontend error messagesIan Lance Taylor
shift1.go:76:16: error: shift of non-integer operand shift1.go:77:16: error: shift of non-integer operand Change-Id: I48584c0b01f9f6912a93b5f9bba55b5803fbeced Reviewed-on: https://go-review.googlesource.com/c/go/+/273888 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-06cmd/compile: rewrite untyped constant conversion logicMatthew Dempsky
This CL detangles the hairy mess that was convlit+defaultlit. In particular, it makes the following changes: 1. convlit1 now follows the standard typecheck behavior of setting "n.Type = nil" if there's an error. Notably, this means for a lot of test cases, we now avoid reporting useless follow-on error messages. For example, after reporting that "1 << s + 1.0" has an invalid shift, we no longer also report that it can't be assigned to string. 2. Previously, assignconvfn had some extra logic for trying to suppress errors from convlit/defaultlit so that it could provide its own errors with better context information. Instead, this extra context information is now passed down into convlit1 directly. 3. Relatedly, this CL also removes redundant calls to defaultlit prior to assignconv. As a consequence, when an expression doesn't make sense for a particular assignment (e.g., assigning an untyped string to an integer), the error messages now say "untyped string" instead of just "string". This is more consistent with go/types behavior. 4. defaultlit2 is now smarter about only trying to convert pairs of untyped constants when it's likely to succeed. This allows us to report better error messages for things like 3+"x"; instead of "cannot convert 3 to string" we now report "mismatched types untyped number and untyped string". Passes toolstash-check. Change-Id: I26822a02dc35855bd0ac774907b1cf5737e91882 Reviewed-on: https://go-review.googlesource.com/c/go/+/187657 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2017-12-01cmd/compile: permit indices of certain non-constant shiftsRobert Griesemer
Per the decision for #14844, index expressions that are non-constant shifts where the LHS operand is representable as an int are now valid. Fixes #21693. Change-Id: Ifafad2c0c65975e0200ce7e28d1db210e0eacd9d Reviewed-on: https://go-review.googlesource.com/81277 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-24cmd/compile: more error position tests for the typecheckerAlberto Donizetti
This change adds line position tests for several yyerror calls in the typechecker that are currently not tested in any way. Untested yyerror calls were found by replacing them with yerrorl(src.NoXPos, ...) (thus destroying position information in the error), and then running the test suite. No failures means no test coverage for the relevant yyerror call. For #19683 Change-Id: Iedb3d2f02141b332e9bfa76dbf5ae930ad2fddc3 Reviewed-on: https://go-review.googlesource.com/41477 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-05-02all: make copyright headers consistent with one space after periodEmmanuel Odeke
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-07-20test: avoid "declared but not used" errors in shift1.goIan Lance Taylor
I'm improving gccgo's detection of variables that are only set but not used, and it triggers additional errors on this code. The new gccgo errors are correct; gc seems to suppress them due to the other, expected, errors. This change uses the variables so that no compiler will complain. gccgo change is https://golang.org/cl/119920043 . LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/116050043
2013-06-26test/shift1.go: recognize gccgo errorsIan Lance Taylor
R=golang-dev, remyoudompheng, iant CC=golang-dev https://golang.org/cl/10524045
2013-03-21test: more systematic shift testsRobert Griesemer
To be submitted once gc agrees. R=rsc, iant, remyoudompheng CC=golang-dev https://golang.org/cl/7861045
2013-03-16cmd/gc: missing type inference for untyped complex() calls.Rémy Oudompheng
Fixes #5014. R=golang-dev, r, rsc, daniel.morsing CC=golang-dev https://golang.org/cl/7664043
2013-03-04cmd/gc: simplify and fix defaultlit.Rémy Oudompheng
Fixes #4882. Fixes #4936. Fixes #4937. R=golang-dev, dave, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/7432044
2012-02-24test/[n-z]*.go: add documentationRob Pike
R=golang-dev, bradfitz, r CC=golang-dev https://golang.org/cl/5700056
2012-02-16test: use testlib (final 61)Russ Cox
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5671080
2011-09-21test: match gccgo error messagesIan Lance Taylor
bug363.go:13:12: error: invalid context-determined non-integer type for shift operand bug363.go:16:12: error: invalid context-determined non-integer type for shift operand pointer.go:34:6: error: incompatible type in initialization (pointer to interface type has no methods) pointer.go:36:6: error: incompatible type in initialization method2.go:15:1: error: invalid pointer or interface receiver type method2.go:16:1: error: invalid pointer or interface receiver type method2.go:21:1: error: invalid pointer or interface receiver type method2.go:22:1: error: invalid pointer or interface receiver type method2.go:28:15: error: type ‘*Val’ has no method ‘val’ method2.go:33:11: error: reference to undefined field or method ‘val’ shift1.go:19:16: error: invalid context-determined non-integer type for shift operand shift1.go:24:19: error: invalid context-determined non-integer type for shift operand shift1.go:25:17: error: invalid context-determined non-integer type for shift operand shift1.go:18:18: error: shift of non-integer operand shift1.go:26:13: error: floating point constant truncated to integer shift1.go:33:15: error: integer constant overflow shift1.go:34:15: error: integer constant overflow shift1.go:35:17: error: integer constant overflow R=golang-dev, r CC=golang-dev https://golang.org/cl/5081051
2011-08-16errchk: allow multiple patternsRuss Cox
// ERROR "pattern1" "pattern2" means that there has to be one or more lines matching pattern1 and then excluding those, there have to be one or more lines matching pattern2. So if you expect two different error messages from a particular line, writing two separate patterns checks that both errors are produced. Also, errchk now flags lines that produce more errors than expected. Before, as long as at least one error matched the pattern, all the others were ignored. Revise tests to expect or silence these additional errors. R=lvd, r, iant CC=golang-dev https://golang.org/cl/4869044
2011-05-25test: test cases for issue 1708.Robert Griesemer
R=rsc CC=golang-dev https://golang.org/cl/4548058