diff mbox

gccgo patch committed: avoid knock-on errors with impossibly large types

Message ID CAOyqgcWO2+tYW5tcGj+Y-Yp14_0k7T_7+Cx2oW8kN6qBSOex8w@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 26, 2016, 10:35 p.m. UTC
This patch by Chris Manghane patches the Go frontend to avoid knock-on
errors when working with impossibly large types.  This fixes
https://golang.org/issue/12938.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 232239)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-c375f3bf470f94220149b486c947bb3eb57cde7d
+731941c155214d6158fa800e52ab3225c0b55f73
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc	(revision 232239)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -2550,6 +2550,8 @@  Type::backend_type_size(Gogo* gogo, int6
 {
   if (!this->is_backend_type_size_known(gogo))
     return false;
+  if (this->is_error_type())
+    return false;
   Btype* bt = this->get_backend_placeholder(gogo);
   *psize = gogo->backend()->type_size(bt);
   if (*psize == -1)
@@ -6453,7 +6455,7 @@  Array_type::slice_gc_symbol(Gogo* gogo,
   (*vals)->push_back(Expression::make_integer_ul(opval, uintptr_type, bloc));
   (*vals)->push_back(*offset);
 
-  if (element_size != 0)
+  if (element_size != 0 && ok)
     (*vals)->push_back(Expression::make_gc_symbol(element_type));
   this->advance_gc_offset(offset);
 }
@@ -6488,7 +6490,7 @@  Array_type::array_gc_symbol(Gogo* gogo,
   Type* element_type = this->element_type();
   if (bound < 1 || !element_type->has_pointer())
     this->advance_gc_offset(offset);
-  else if (bound == 1 || iwidth <= 4 * pwidth)
+  else if (ok && (bound == 1 || iwidth <= 4 * pwidth))
     {
       for (unsigned int i = 0; i < bound; ++i)
 	Type::gc_symbol(gogo, element_type, vals, offset, stack_size);