compiler: check for nil receiver in value method
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 1 Feb 2018 01:38:52 +0000 (01:38 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 1 Feb 2018 01:38:52 +0000 (01:38 +0000)
commit22149e37f7537843947003b4c7df76b69dd287ac
tree388a01b7e313a8a26c20afbf0aa8050f869359bb
parentee249a767f6d80ecc1037432ced41bba7e073268
compiler: check for nil receiver in value method

    We already dereference the pointer to copy the value, but if the
    method does not use the value then the pointer dereference may be
    optimized away.  Do an explicit nil check so that we get the panic
    that is required.

    Fixes golang/go#19806

    Reviewed-on: https://go-review.googlesource.com/91275

* go.go-torture/execute/printnil.go: New test.

From-SVN: r257280
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc
gcc/testsuite/go.go-torture/execute/printnil.go [new file with mode: 0644]