public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: force non-abstract type in switch statement
@ 2014-12-16 21:37 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2014-12-16 21:37 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 314 bytes --]

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

[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 622 bytes --]

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());

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-16 21:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 21:37 Go patch committed: force non-abstract type in switch statement Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).