diff mbox

Go patch committed: force non-abstract type in switch statement

Message ID CAOyqgcXMe1evu=UProJ_aTW_rxr-Qz1aE_m3YTROxQZBT+xgig@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Dec. 16, 2014, 9:36 p.m. UTC
This patch by Chris Manghane fixes a Go compiler crash when using a
switch statement where the switch value is an untyped constant.  This
is not normally a useful thing to do, but of course the compiler
should not crash.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 38dd5fea8cc1 go/statements.cc
--- a/go/statements.cc	Tue Dec 16 11:14:02 2014 -0800
+++ b/go/statements.cc	Tue Dec 16 13:00:30 2014 -0800
@@ -3857,7 +3857,11 @@ 
   Expression* val = this->val_;
   if (val == NULL)
     val = Expression::make_boolean(true, loc);
-  Temporary_statement* val_temp = Statement::make_temporary(NULL, val, loc);
+
+  Type* type = val->type();
+  if (type->is_abstract())
+    type = type->make_non_abstract_type();
+  Temporary_statement* val_temp = Statement::make_temporary(type, val, loc);
   b->add_statement(val_temp);
 
   this->clauses_->lower(b, val_temp, this->break_label());