compiler: fix crashes on cyclic var/type references
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 4 Jun 2018 19:10:05 +0000 (19:10 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 4 Jun 2018 19:10:05 +0000 (19:10 +0000)
commitf0ebf6e3229d88be4bc8d13b219327a7a073df83
treebac6ab9a7cb11017d4e4ab53577eebb573d2e3dc
parente68086c43226ee8ada8ac71365f571a3d3ad2a0a
compiler: fix crashes on cyclic var/type references

    This patch fixes type traversal to avoid compiler crashes for test
    cases where a type T includes an expression that refers back to the
    type without actually explicitly mentioning T. Examples include

      var x [uintptr(unsafe.Sizeof(&x))]byte
      var a [len(a)]int

    The fix involves expanding the set of types that the traversal code
    "remembers" (to avoid cycles) to include array types, and introducing an
    additional guard in Builtin_call_expression::do_is_constant to catch
    cyclic type constructs.

    Fixes golang/go#25299
    Fixes golang/go#25679
    Fixes golang/go#25315
    Fixes golang/go#25680

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

From-SVN: r261168
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/gogo.cc