This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Avoid crashes on erroneous input


This patch to the Go frontend avoids some compiler crashes on erroneous
inputs.  It also makes some minor fixes to some comments.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r 4f7eddf7a851 go/backend.h
--- a/go/backend.h	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/backend.h	Wed Feb 15 06:31:05 2012 -0800
@@ -126,7 +126,9 @@
 
   // Fill in a placeholder pointer type as a pointer.  This takes a
   // type returned by placeholder_pointer_type and arranges for it to
-  // point to to_type.  Returns true on success, false on failure.
+  // point to the type that TO_TYPE points to (that is, PLACEHOLDER
+  // becomes the same type as TO_TYPE).  Returns true on success,
+  // false on failure.
   virtual bool
   set_placeholder_pointer_type(Btype* placeholder, Btype* to_type) = 0;
 
diff -r 4f7eddf7a851 go/gogo.cc
--- a/go/gogo.cc	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/gogo.cc	Wed Feb 15 06:31:05 2012 -0800
@@ -4180,6 +4180,11 @@
 					    package != NULL,
 					    Gogo::is_hidden_name(name),
 					    this->location_);
+	  else if (function == NULL)
+	    {
+	      go_assert(saw_errors());
+	      bvar = backend->error_variable();
+	    }
 	  else
 	    {
 	      tree fndecl = function->func_value()->get_decl();
diff -r 4f7eddf7a851 go/types.cc
--- a/go/types.cc	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/types.cc	Wed Feb 15 06:31:05 2012 -0800
@@ -3595,7 +3595,7 @@
   return this->to_type_->hash_for_method(gogo) << 4;
 }
 
-// The tree for a pointer type.
+// Get the backend representation for a pointer type.
 
 Btype*
 Pointer_type::do_get_backend(Gogo* gogo)
@@ -5345,6 +5345,7 @@
 }
 
 // Return the backend representation of the element type.
+
 Btype*
 Array_type::get_backend_element(Gogo* gogo)
 {
@@ -7567,6 +7568,11 @@
 	  this->find_type_->add_dependency(type->named_type());
 	  break;
 
+	case Type::TYPE_NAMED:
+	case Type::TYPE_FORWARD:
+	  go_assert(saw_errors());
+	  break;
+
 	case Type::TYPE_VOID:
 	case Type::TYPE_SINK:
 	case Type::TYPE_FUNCTION:
@@ -7575,8 +7581,6 @@
 	case Type::TYPE_MAP:
 	case Type::TYPE_CHANNEL:
 	case Type::TYPE_INTERFACE:
-	case Type::TYPE_NAMED:
-	case Type::TYPE_FORWARD:
 	default:
 	  go_unreachable();
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]