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: Don't crash on invalid use of multiple results


There were some cases in the Go frontend where an invalid use of a
function call returning multiple results could cause the compiler to
crash.  For example, it could happen when returning multiple results in
a function which returned an interface type.  This patch avoids the
crashes in invalid programs.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 5382ded0e9b4 go/types.cc
--- a/go/types.cc	Thu Dec 23 16:32:07 2010 -0800
+++ b/go/types.cc	Thu Dec 23 16:46:39 2010 -0800
@@ -3253,26 +3253,35 @@
  protected:
   bool
   do_has_pointer() const
-  { gcc_unreachable(); }
+  {
+    gcc_assert(saw_errors());
+    return false;
+  }
 
   tree
   do_get_tree(Gogo*);
 
   tree
   do_get_init_tree(Gogo*, tree, bool)
-  { gcc_unreachable(); }
+  {
+    gcc_assert(saw_errors());
+    return error_mark_node;
+  }
 
   Expression*
   do_type_descriptor(Gogo*, Named_type*)
-  { gcc_unreachable(); }
+  {
+    gcc_assert(saw_errors());
+    return Expression::make_error(UNKNOWN_LOCATION);
+  }
 
   void
   do_reflection(Gogo*, std::string*) const
-  { gcc_unreachable(); }
+  { gcc_assert(saw_errors()); }
 
   void
   do_mangled_name(Gogo*, std::string*) const
-  { gcc_unreachable(); }
+  { gcc_assert(saw_errors()); }
 
  private:
   // The expression being called.

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