Commit 8b06e188 by Ian Lance Taylor

compiler: Logical operators should yield untyped bool for untyped operands.

Fixes issue 6671 for gccgo.

From-SVN: r217094
parent 4456c6bf
......@@ -5314,15 +5314,6 @@ Binary_expression::do_determine_type(const Type_context* context)
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)
{
......
// errorcheck
// compile
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......@@ -9,5 +9,5 @@ package foo
type mybool bool
var x, y = 1, 2
var _ mybool = x < y && x < y // ERROR "cannot use"
var _ mybool = x < y || x < y // ERROR "cannot use"
var _ mybool = x < y && x < y
var _ mybool = x < y || x < y
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment