From patchwork Tue Dec 4 06:44:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Go patch committed: Reject nil == nil Date: Mon, 03 Dec 2012 20:44:23 -0000 From: Ian Taylor X-Patchwork-Id: 203570 Message-Id: To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com This patch to the Go frontend rejects invalid comparisons in Go of nil with nil. These comparisons have no type and no particular meaning, and they are not permitted. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 4d8871577da5 go/expressions.cc --- a/go/expressions.cc Mon Dec 03 22:22:34 2012 -0800 +++ b/go/expressions.cc Mon Dec 03 22:38:58 2012 -0800 @@ -5610,6 +5610,11 @@ || this->op_ == OPERATOR_GT || this->op_ == OPERATOR_GE) { + if (left_type->is_nil_type() && right_type->is_nil_type()) + { + this->report_error(_("invalid comparison of nil with nil")); + return; + } if (!Type::are_assignable(left_type, right_type, NULL) && !Type::are_assignable(right_type, left_type, NULL)) {