Patchwork Go patch committed: Don't crash on erroneous go or defer statement

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

Comments

Ian Taylor - Dec. 16, 2010, 12:15 a.m.
This patch to the Go frontend avoids crashing if a go or defer statement
is used with a bad function call.  Bootstrapped and tested on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r ab74f84268fd go/statements.cc
--- a/go/statements.cc	Wed Dec 15 16:01:46 2010 -0800
+++ b/go/statements.cc	Wed Dec 15 16:11:04 2010 -0800
@@ -1812,7 +1812,13 @@ 
 
   Call_expression* ce = this->call_->call_expression();
   Function_type* fntype = ce->get_function_type();
-  if (fntype == NULL || this->is_simple(fntype))
+  if (fntype == NULL)
+    {
+      gcc_assert(saw_errors());
+      this->set_is_error();
+      return false;
+    }
+  if (this->is_simple(fntype))
     return false;
 
   Expression* fn = ce->fn();