Patchwork Go patch committed: Don't crash on erroneous result variable

login
register
mail settings
Submitter Ian Taylor
Date Dec. 7, 2010, 10:27 p.m.
Message ID <mcroc8xnrqi.fsf@google.com>
Download mbox | patch
Permalink /patch/74609/
State New
Headers show

Comments

Ian Taylor - Dec. 7, 2010, 10:27 p.m.
This Go frontend patch avoids a crash when a result variable has an
erroneous type.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 2580746c6973 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Mon Dec 06 22:25:42 2010 -0800
+++ b/go/gogo-tree.cc	Tue Dec 07 13:45:07 2010 -0800
@@ -1550,14 +1550,18 @@ 
       else if ((*p)->is_result_variable())
 	{
 	  tree var_decl = (*p)->get_tree(gogo, named_function);
-	  if ((*p)->result_var_value()->is_in_heap())
+	  if (var_decl != error_mark_node
+	      && (*p)->result_var_value()->is_in_heap())
 	    {
 	      gcc_assert(TREE_CODE(var_decl) == INDIRECT_REF);
 	      var_decl = TREE_OPERAND(var_decl, 0);
 	    }
-	  gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
-	  DECL_CHAIN(var_decl) = declare_vars;
-	  declare_vars = var_decl;
+	  if (var_decl != error_mark_node)
+	    {
+	      gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
+	      DECL_CHAIN(var_decl) = declare_vars;
+	      declare_vars = var_decl;
+	    }
 	}
     }
   *pp = NULL_TREE;