]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: Don't crash if writing type functions too late due to error.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 7 Mar 2012 21:53:34 +0000 (21:53 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 7 Mar 2012 21:53:34 +0000 (21:53 +0000)
From-SVN: r185080

gcc/go/gofrontend/gogo.h
gcc/go/gofrontend/types.cc

index 008c8a09872c0b8f9ea5ffcd2002a8753dcd40b1..6c77c3bd9e949e2dfedc13b4076c40aae7c1d23a 100644 (file)
@@ -398,6 +398,11 @@ class Gogo
   void
   write_specific_type_functions();
 
+  // Whether we are done writing out specific type functions.
+  bool
+  specific_type_functions_are_written() const
+  { return this->specific_type_functions_are_written_; }
+
   // Traverse the tree.  See the Traverse class.
   void
   traverse(Traverse*);
index d3a75f425d148bbd1c75cfd26bdbf03abd6a74c9..03f1b3ea0c6efb488a4c24f80ed3f2dedfa5ea0b 100644 (file)
@@ -1790,6 +1790,12 @@ Type::write_specific_type_functions(Gogo* gogo, Named_type* name,
 {
   Location bloc = Linemap::predeclared_location();
 
+  if (gogo->specific_type_functions_are_written())
+    {
+      go_assert(saw_errors());
+      return;
+    }
+
   Named_object* hash_fn = gogo->start_function(hash_name, hash_fntype, false,
                                               bloc);
   gogo->start_block(bloc);