1
0
mirror of https://github.com/golang/go synced 2024-09-30 05:24:29 -06:00
go/test
Josh Bleecher Snyder c9446398e8 cmd/compile: allow composite literal structs with _ fields
Given code such as

type T struct {
  _ string
}

func f() {
  var x = T{"space"}
  // ...
}

the compiler rewrote the 'var x' line as

var x T
x._ = "space"

The compiler then rejected the assignment to
a blank field, thus rejecting valid code.

It also failed to catch a number of invalid assignments.
And there were insufficient checks for validity
when emitting static data, leading to ICEs.

To fix, check earlier for explicit blanks field names,
explicitly handle legit blanks in sinit,
and don't try to emit static data for nodes
for which typechecking has failed.

Fixes #19482

Change-Id: I594476171d15e6e8ecc6a1749e3859157fe2c929
Reviewed-on: https://go-review.googlesource.com/38006
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-07 22:01:18 +00:00
..
alias3.dir [dev.typealias] cmd/compile: export/import test cases for type aliases 2017-01-20 05:55:53 +00:00
bench test/bench/go1: fix typo in parserdata_test.go comment 2017-03-22 03:23:16 +00:00
chan
ddd2.dir
dwarf
fixedbugs cmd/compile: allow composite literal structs with _ fields 2017-04-07 22:01:18 +00:00
import2.dir
import4.dir
interface cmd/compile: do more type conversion inline 2016-11-02 21:33:03 +00:00
intrinsic.dir cmd/compile: intrinsics for math/bits.TrailingZerosX 2017-03-16 02:44:16 +00:00
ken
linkname.dir cmd/compile: include linknames in export data 2017-02-08 20:59:45 +00:00
method4.dir
safe
stress
syntax cmd/compile/internal/parser: improved a couple of error messages 2017-02-24 18:54:36 +00:00
uintptrescapes.dir
64bit.go
235.go
alg.go
alias1.go
alias2.go [dev.typealias] cmd/compile: declare methods after resolving receiver type 2017-01-25 08:04:17 +00:00
alias3.go [dev.typealias] cmd/compile: export/import test cases for type aliases 2017-01-20 05:55:53 +00:00
alias.go
append.go
args.go
assign1.go
assign.go
atomicload.go
bigalg.go
bigmap.go
blank1.go
blank.go
bom.go
bombad.go
bounds.go
chancap.go
chanlinear.go
char_lit1.go
char_lit.go
checkbce.go cmd/compile: improve generic rules for BCE based on AND operations. 2017-03-04 16:13:07 +00:00
clearfat.go
closedchan.go
closure1.go
closure2.go
closure.go
cmp6.go
cmp.go
cmplx.go
cmplxdivide1.go runtime: make complex division c99 compatible 2017-03-15 22:45:17 +00:00
cmplxdivide.c runtime: make complex division c99 compatible 2017-03-15 22:45:17 +00:00
cmplxdivide.go runtime: make complex division c99 compatible 2017-03-15 22:45:17 +00:00
complit1.go
complit.go
compos.go
const1.go
const2.go
const3.go
const4.go
const5.go
const6.go
const.go cmd/compile: fix compiler bug for constant equality comparison 2016-09-17 01:12:24 +00:00
convert1.go
convert2.go cmd/compile: ignore struct tags when converting structs 2016-10-04 17:10:47 +00:00
convert3.go
convert.go
convlit1.go
convlit.go
convT2X.go
copy.go
crlf.go
ddd1.go cmd/compile: improve not enough / too many arguments errors 2016-10-28 21:53:07 +00:00
ddd2.go
ddd.go
decl.go
declbad.go
defer.go
deferfin.go
deferprint.go
deferprint.out
devirt.go cmd/compile: de-virtualize interface calls 2017-03-14 18:49:23 +00:00
divide.go
divmod.go
empty.go
env.go
eof1.go
eof.go
errchk
escape2.go cmd/compile: ignore some dead code during escape analysis 2017-02-27 21:31:04 +00:00
escape2n.go
escape3.go
escape4.go
escape5.go cmd/compile: unnamed parameters do not escape 2017-03-24 17:14:00 +00:00
escape_array.go
escape_because.go cmd/compile: add explicit 'where' to EscStep data for explanations 2016-10-26 18:46:59 +00:00
escape_calls.go
escape_closure.go cmd/compile/internal/syntax: establish principled position information 2017-02-15 01:33:03 +00:00
escape_field.go
escape_iface.go cmd/compile: avoid leak of dottype expression on double assignment form 2016-10-10 12:09:16 +00:00
escape_indir.go
escape_level.go
escape_map.go
escape_param.go
escape_slice.go
escape_struct_param1.go
escape_struct_param2.go
escape_struct_return.go
escape.go
fibo.go
finprofiled.go
float_lit2.go test/float_lit2: fix expressions in comment 2016-09-14 16:39:47 +00:00
float_lit3.go
float_lit.go
floatcmp.go
for.go
func1.go
func2.go
func3.go
func4.go
func5.go
func6.go
func7.go
func8.go
func.go
funcdup2.go
funcdup.go
gc1.go
gc2.go
gc.go
gcstring.go
goprint.go
goprint.out
goto.go
heapsampling.go
helloworld.go
helloworld.out
if.go
import1.go
import2.go
import4.go
import5.go cmd/compile: be slightly more tolerant in case of certain syntax errors 2017-03-24 20:07:15 +00:00
import6.go cmd/compile/internal/syntax: removed gcCompat code needed to pass orig. tests 2017-02-10 01:22:30 +00:00
import.go
index0.go
index1.go
index2.go
index.go
indirect1.go
indirect.go
init1.go
init.go Revert "cmd/compile: improve error message if init is directly invoked" 2017-03-06 23:48:37 +00:00
initcomma.go
initialize.go
initializerr.go
initloop.go
inline_callers.go runtime: include inlined calls in result of CallersFrames 2017-03-29 17:27:38 +00:00
inline_literal.go cmd/compile: copy literals when inlining 2017-03-03 21:29:32 +00:00
inline_variadic.go cmd/compile: generate code that type checks when inlining variadic functions 2016-11-30 19:46:00 +00:00
inline.go
int_lit.go
intcvt.go
intrinsic_atomic.go cmd/compile: intrinsify Ctz, Bswap on ARM 2016-09-12 19:26:31 +00:00
intrinsic.go cmd/compile: intrinsify Ctz{32,64} and Bswap{32,64} on s390x 2016-09-19 19:03:01 +00:00
iota.go
label1.go
label.go
linkmain_run.go
linkmain.go
linkname.go cmd/compile: include linknames in export data 2017-02-08 20:59:45 +00:00
linkobj.go
linkx_run.go
linkx.go
literal.go
live1.go
live2.go cmd/compile: mark temps with new AutoTemp flag, and use it. 2016-10-31 19:38:50 +00:00
live_syscall.go cmd/compile: mark temps with new AutoTemp flag, and use it. 2016-10-31 19:38:50 +00:00
live.go runtime: add mapdelete_fast* 2017-03-21 06:07:24 +00:00
locklinear.go test: deflake locklinear again 2017-04-05 18:46:31 +00:00
loopbce.go cmd/compile: check loop rescheduling with stack bound, not counter 2017-03-08 18:52:12 +00:00
mallocfin.go
map1.go
map.go
maplinear.go
method1.go
method2.go test: avoid matching file names in errcheck 2016-10-18 05:32:37 +00:00
method3.go
method4.go
method5.go
method.go
named1.go
named.go
nil.go
nilcheck.go
nilptr2.go
nilptr3.go cmd/compile: re-enable nilcheck removal in same block 2017-02-17 19:19:59 +00:00
nilptr4.go
nilptr.go
nosplit.go test: add mipsx case to nosplit.go 2016-12-15 22:43:28 +00:00
notinheap2.go cmd/compile: add go:notinheap type pragma 2016-10-15 17:58:14 +00:00
notinheap.go cmd/compile/internal/gc: inline typedcl0 and typedcl1 2017-02-01 22:52:32 +00:00
nowritebarrier.go cmd/compile, runtime: add go:yeswritebarrierrec pragma 2016-10-15 17:58:11 +00:00
nul1.go cmd/compile/internal/gc: enable new parser by default 2016-10-25 22:28:40 +00:00
opt_branchlikely.go cmd/compile: insert scheduling checks on loop backedges 2017-01-09 21:01:29 +00:00
parentype.go
peano.go
phiopt.go test: re-enable phi optimization test 2016-09-13 20:06:13 +00:00
print.go
print.out
printbig.go
printbig.out
prove.go cmd/compile/internal/gc: improve comparison with constant strings 2017-04-07 15:40:25 +00:00
range.go cmd/compile: fix assignment order in string range loop 2017-02-28 08:23:52 +00:00
recover1.go
recover2.go
recover3.go
recover4.go
recover.go
reflectmethod1.go
reflectmethod2.go
reflectmethod3.go
reflectmethod4.go
rename1.go
rename.go
reorder2.go
reorder.go cmd/compile: Ensure left-to-right assignment 2017-02-11 21:46:21 +00:00
return.go
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rotate.go
run.go test: allow flags in run action 2017-03-29 17:22:00 +00:00
rune.go
runtime.go cmd/compile/internal/gc: separate builtin and real runtime packages 2017-03-01 01:06:32 +00:00
shift1.go
shift2.go
sieve.go
sigchld.go
sigchld.out
simassign.go
sinit_run.go
sinit.go
sizeof.go
slice3.go
slice3err.go
slicecap.go
sliceopt.go cmd/compile: use masks instead of branches for slicing 2016-10-27 20:22:49 +00:00
solitaire.go
stack.go
strength.go
string_lit.go
stringrange.go
struct0.go
switch2.go
switch3.go
switch4.go
switch5.go cmd/compile/internal/syntax: removed gcCompat code needed to pass orig. tests 2017-02-10 01:22:30 +00:00
switch6.go cmd/compile: improve error for wrong type in switch 2017-02-02 17:36:43 +00:00
switch.go
tinyfin.go
torture.go
turing.go
typecheck.go
typecheckloop.go
typeswitch1.go
typeswitch2.go cmd/compile/internal/syntax: removed gcCompat code needed to pass orig. tests 2017-02-10 01:22:30 +00:00
typeswitch3.go cmd/compile: add test for non interface type switch 2017-03-25 22:52:54 +00:00
typeswitch.go
uintptrescapes2.go cmd/compile: mark temps with new AutoTemp flag, and use it. 2016-10-31 19:38:50 +00:00
uintptrescapes.go
undef.go
utf.go
varerr.go
varinit.go
writebarrier.go cmd/compile: do not use "oaslit" for global 2017-02-07 17:23:23 +00:00
zerodivide.go test: lock in test for _ assignment evaluation/zerodivide panic 2016-12-23 17:35:24 +00:00