Patchwork Go patch committed: Avoid endless loop checking for pointer type

login
register
mail settings
Submitter Ian Taylor
Date Dec. 24, 2010, 12:48 a.m.
Message ID <mcr1v58vvv0.fsf@google.com>
Download mbox | patch
Permalink /patch/76562/
State New
Headers show

Comments

Ian Taylor - Dec. 24, 2010, 12:48 a.m.
This patch to the Go frontend avoids an endless type loop when checking
whether an invalid type is or contains a pointer.  Bootstrapped and ran
Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

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.