This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't inherit types of logical operators
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Wed, 09 Oct 2013 20:28:23 -0700
- Subject: Go patch committed: Don't inherit types of logical operators
- Authentication-results: sourceware.org; auth=none
The Go frontend has a minor type error: it inherited the types of
operands of logical operators (&& and ||) from the context. This patch
fixes the bug. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline. Will commit to 4.8
branch when it reopens.
Ian
diff -r 06003bcbf6cc go/expressions.cc
--- a/go/expressions.cc Wed Oct 09 17:03:00 2013 -0700
+++ b/go/expressions.cc Wed Oct 09 20:24:11 2013 -0700
@@ -5606,6 +5606,15 @@
subcontext.type = NULL;
}
+ if (this->op_ == OPERATOR_ANDAND || this->op_ == OPERATOR_OROR)
+ {
+ // For a logical operation, the context does not determine the
+ // types of the operands. The operands must be some boolean
+ // type but if the context has a boolean type they do not
+ // inherit it. See http://golang.org/issue/3924.
+ subcontext.type = NULL;
+ }
+
// Set the context for the left hand operand.
if (is_shift_op)
{