When the Go frontend converts a shortcut operator like && or || to an if
statement, it used the wrong type for the temporary variable.  It always
used bool, but the operator could be using a named version of bool.
This matters when the type has methods.  This patch fixes the problem.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.8 branch.

Ian

diff -r 35afa97b6c21 go/gogo.cc
--- a/go/gogo.cc	Tue Sep 17 15:09:45 2013 -0700
+++ b/go/gogo.cc	Wed Sep 18 11:30:33 2013 -0700
@@ -2367,7 +2367,7 @@
   Block* retblock = new Block(enclosing, loc);
   retblock->set_end_location(loc);
 
-  Temporary_statement* ts = Statement::make_temporary(Type::lookup_bool_type(),
+  Temporary_statement* ts = Statement::make_temporary(shortcut->type(),
 						      left, loc);
   retblock->add_statement(ts);
 

Reply via email to