Patchwork Go patch committed: Don't store error types in ->GENERIC hash table

login
register
mail settings
Submitter Ian Taylor
Date Dec. 15, 2010, 1:46 a.m.
Message ID <mcrmxo76c6f.fsf@google.com>
Download mbox | patch
Permalink /patch/75599/
State New
Headers show

Comments

Ian Taylor - Dec. 15, 2010, 1:46 a.m.
This patch fixes the Go frontend to not store error types in the hash
table which maps from Go Types to GENERIC types.  This avoids getting
unexpected invalid type mappings, such as for type descriptors.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 0c187387eb58 go/types.cc
--- a/go/types.cc	Tue Dec 14 17:04:05 2010 -0800
+++ b/go/types.cc	Tue Dec 14 17:43:29 2010 -0800
@@ -791,6 +791,9 @@ 
       || this->named_type() != NULL)
     return this->get_tree_without_hash(gogo);
 
+  if (this->is_error_type())
+    return error_mark_node;
+
   // To avoid confusing GIMPLE, we need to translate all identical Go
   // types to the same GIMPLE type.  We use a hash table to do that.
   // There is no need to use the hash table for named types, as named
@@ -807,6 +810,14 @@ 
 
   tree t = this->get_tree_without_hash(gogo);
 
+  // Don't store errors in the hash table.  This type might be a
+  // pointer to an error type or something like that.  Since error
+  // types are identical to everything else, that could cause us to
+  // return error_mark_node for pointers to any type, which will then
+  // confuse us later.
+  if (t == error_mark_node)
+    return error_mark_node;
+
   if (ins.first->second == NULL_TREE)
     ins.first->second = t;
   else